Path: utzoo!utgpu!water!watmath!clyde!rutgers!mit-eddie!uw-beaver!cornell!rochester!udel!gatech!hao!ames!umd5!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Is NULL == 0 always true? Keywords: NULL Message-ID: <7013@brl-smoke.ARPA> Date: 9 Jan 88 09:57:54 GMT References: <134@soleil.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 15 In article <134@soleil.UUCP> geigel@soleil.UUCP (Joe Geigel) writes: > Is NULL always equivalent to the value 0? NULL is a macro #defined by and occasionally other headers. It is whatever it is #defined to be! However, as we discuss in this newsgroup about once a year, the ways that it is intended to be used (as a generic null pointer constant) require that it be #defined to be just the integer constant 0, in pre-ANSI C, or either 0 or (void *)0 in ANSI C. Some implementations currently #define it as (char *)0, but whoever did that was operating under a misconception. > if (ptr = strchr (str,'\')) { This is, has been, and will continue to be a correct way to test for a null pointer. However, '\' is nonportable.