Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) 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: <1085@virtech.UUCP> Date: 29 Aug 89 00:56:37 GMT References: <127@cica.cica.indiana.edu> Distribution: na Organization: Virtual Technologies Inc Lines: 23 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? Because C comparisons only work on scalar values. the compare that you were using is actually comparing the pointer fld to the address of the ".," constant (this should never be true). -- +-----------------------------------------------------------------------+ | Conor P. Cahill uunet!virtech!cpcahil 703-430-9247 ! | Virtual Technologies Inc., P. O. Box 876, Sterling, VA 22170 | +-----------------------------------------------------------------------+