"p ? a : b"

Chip Salzenberg chip at tct.uucp
Tue Oct 2 00:25:38 AEST 1990


According to ott at guug.guug.de (Joachim Ott Munich-Germany):
>In article <bashsco at dce.ie>, em at dce.ie (Eamonn McManus) writes:
>> /* The stupid Microsoft compiler warns about the ?: below.  Ignore it.
>>    Better still, use GNU C. */
>> su(pwd, login, shell ? shell : pwd->pw_shell, argv + i - 1);
>
>Not really stupid (i must admit to microsoft). 'shell ?' means
>'shell != 0' and *not* 'shell != NULL'. You should not rely on
>NULL being the same as 0.

It is true that NULL is not always defined literally as "0".
However, "pointer != NULL" and "pointer != 0" are equivalent.
The quoted C statement is portable and correct.

Further discussion should take place in comp.lang.c.

(Anyone who disagrees with my statement above should read the
Frequently Asked Questions article in comp.lang.c before posting.)
-- 
Chip Salzenberg at Teltronics/TCT     <chip at tct.uucp>, <uunet!pdn!tct!chip>



More information about the Comp.unix.sysv386 mailing list