Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!uwvax!rocky.cs.wisc.edu!g-tookey From: g-tookey@rocky.cs.wisc.edu. (Richard Schaut) Newsgroups: comp.sys.ibm.pc Subject: Re: why does this compare fail in TC2.0? Keywords: C question about compares in turbo c 2.0 Message-ID: <8261@spool.cs.wisc.edu> Date: 29 Aug 89 15:16:55 GMT References: <127@cica.cica.indiana.edu> <1085@virtech.UUCP> Sender: news@spool.cs.wisc.edu Reply-To: g-tookey@rocky.CS.WISC.EDU (Richard Schaut) Distribution: na Organization: U of Wisconsin CS Dept Lines: 30 In article <127@cica.cica.indiana.edu>, burleigh@cica.cica.indiana.edu (Frank Burleigh) writes: > 1. in a test file that has some missings, the compare fails every time, > even though i can see via tc's watch that fld actually holds ".," with > NULL in fld[2]. thus, execution always drops through to the else > clause. i *have* a different version: > > if( fld[0] == '.' && fld[1] == ',' ) ... > > which works correctly. why does the compare fail? If you want to compare strings, use strcmp or strncmp. Also, for what you are doing, look up strtol and sscanf in the TC manuals. Finally, a bit of advice I see quite often on the Borland forum on compuserve: turn on ALL warnings, prototype EVERYTHING, and get your code to compile without any warnings and without using any casts (i.e. by including the appropriate header files). By doing that, you let the compiler catch most of your errors. No sense in trying to do that which the compiler can do better :-). Rick Please send e-mail to: schaut@madnix.UUCP ArpaNet: madnix!schaut@cs.wisc.edu UseNet: ...uwvax!astroatc!nicmad!madnix!schaut {decvax!att}! I am posting this through a friend's account. His consent to my use of his account in no way implies his consent to responsibility for the opinions expressed herein.