[comp.unix.sysv386] "p ? a : b"

chip@tct.uucp (Chip Salzenberg) (10/01/90)

According to ott@guug.guug.de (Joachim Ott Munich-Germany):
>In article <bashsco@dce.ie>, em@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@tct.uucp>, <uunet!pdn!tct!chip>