From: Richard Stamp
Newsgroups: comp.lang.c
Subject: Re: NULL vs Int 0
Date: Sun, 7 Feb 1999 16:57:20 -0000
Message-ID: <>
References: <79fckc$jc2$> <79fdke$1r8$> <79ijbq$njb$> <> <>

Lawrence Kirby wrote in message <>... >Null pointers work perfectly well on platforms where "address 0" can
>point to a valid object. However there is a reason for why a null pointer
>should compare equal to zero and that is that tests like if ()
>statements do the natural thing. Given that it makes sense for null
>pointer constants to be defined in a consistent way.

The reason people find this confusing (and it's clear that lots of people do find it confusing; I remember being very confused myself a while ago) is, I think, that 0 changes in meaning depending on the situation in which it's used.

Normally 0 means integer zero, but in some cases it means null pointer. It's natural to try to find a link between these and think of the null pointer as pointing to address 0, but as the FAQ makes clear this isn't a valid approach.

We're all familiar with operators changing their meaning according to context (the - operator behaving quite differently with pointers than with numbers, for example), but it's more surprising to see a constant acting that way.