Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site dg_rtp.UUCP Path: utzoo!watmath!clyde!burl!ulysses!bellcore!decvax!mcnc!rti-sel!dg_rtp!throopw From: throopw@dg_rtp.UUCP Newsgroups: net.unix-wizards,net.lang.c Subject: Re: Need help with C (struct comparison) Message-ID: <124@dg_rtp.UUCP> Date: Sun, 2-Feb-86 19:15:35 EST Article-I.D.: dg_rtp.124 Posted: Sun Feb 2 19:15:35 1986 Date-Received: Tue, 4-Feb-86 03:24:16 EST Followup-To: net.lang.c Lines: 40 Xref: watmath net.unix-wizards:16638 net.lang.c:7751 > struct datestruct date; > struct dbstruct dbase[63]; > > I try to do a comparison between these, i.e. > > ( date == dbase[loop].date ) > > but the compiler blows up on this, saying the two are incompatible. K&R C doesn't allow composite variables (arrays, structures, like that) to be used in primitive operations (assignment, comparison, like that). Now, structure assignment works in many compilers nowadays, but I'm not sure about comparison. Our typechecker barfs on this sort of thing, and so does our compiler. The compiler says: if( x==y ) ^ The binary operator "==" works only on integer, floating-point and pointer data types. which is pretty much to the point. In any event, just what did you want the comparison to do? Compare for bit-wise equality? Including padding? What if characters have multiple representations for the "same" character on your machine? Maybe component-by-component equality? With just what semantics? And so on and on. > I'm almost positive I've done this sort of thing before, and can't > seem to find why it won't work. Anyone have any ideas/suggestions > as to why this is? I assume that when you did it before, the item you were grabbing out of the array of structures was *not* a composite type, but rather belonged to integer, floating-point or pointer type. > Also, is there a better newsgroup for these type of inquiries? Yes indeedy, called "net.lang.c". Followup has been redirected there. -- Wayne Throop at Data General, RTP, NC !mcnc!rti-sel!dg_rtp!throopw