[comp.sys.mac.programmer] NULL pointer problem in THINK_C?

kocks@jessica.stanford.edu (Peter Kocks) (08/14/90)

I ran into a strange problem the other day using THINK_C.

Consider the following two codes....

a)
while(mypointer != NULL){ .... }

b)
while(((int)(mypointer)) != 0){ ... }


I found that a) does not work.  I.e. when mypointer == NULL (as shown
by the debugger), the "while" statement continues to execute.  On the
other hand (b)  (which should be functionaly equilavent) does work.

I am using think_c 4.0, with the scanf patch, but no others.

Please respond also be e-mail.

-- Peter Kocks
   kocks@jessica.stanford.edu

P.S

Debugger Notes:

Variable        :   Value
-------------------------
mypointer       : 0x000...
NULL            : 0x000...
mypointer != NULL : 1
mypointer == NULL : 0