if(p)

Chris Torek chris at umcp-cs.UUCP
Tue Oct 8 17:28:00 AEST 1985


> In [K&R, section] 9.3 ``the expression is 0'' cannot mean the
> constant 0, but rather that the expression evaluates to zero.
> There are plenty of uses of ``0'', ``zero'', and ``non-zero''
> referring to what an expression evaluates to, and only three
> references that I've found (7.7, 7.13 and 7.14) to the special
> meaning of the constant 0. [...]
> 
> In Sum:  it seems to me that ``if (p != NULL)'' is portable (NULL
> being 0) but ``if (p)'' is not.
> 
> Please correct me if I be wrong, before I mislead countless others.

Consider yourself corrected.  This rather loose definition in K&R
is one of the reasons there is an ANSI standard in the works.

In general, if K&R says `<x> is so', then you can be pretty darn
sure that <x> is so; but if they do not say `<y> is not', you will
just have to make your best guess.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.lang.c mailing list