use of if (!cptr) and if (cptr), where cptr is a *

Jeff Leyser jeffl at nc386.uucp
Tue Jul 25 05:46:46 AEST 1989


In post <10562 at smoke.BRL.MIL>, gwyn at brl.arpa (Doug Gwyn) says:
!In article <10100 at mpx2.mpx.com> erik at mpx2.mpx.com (Erik Murrey) writes:
!>Now, what happens with:
!>if (cptr == 0) ?  Does the compiler cast the cptr to an int, and loose
!>the descriptor?  (And tell is that it is null?)
!
!We've already explained this, but here it is again:  Just because you
!see "0" in the source code does not mean that it acts an integer constant.

OK, this may be meaningless, but out of curiosity is:

	if (cptr == (int) 0)

illegal C, or simply compleat garbage?

-- 
Jeff Leyser                                     ...!uunet!hal!ncoast!nc386!jeffl



More information about the Comp.lang.c mailing list