the nil pointer is not zero

Stephen Clamage steve at taumet.com
Tue Nov 20 03:33:52 AEST 1990


mcdonald at aries.scs.uiuc.edu (Doug McDonald) writes:

|The point is that if it were indeed actually all bits zero, in all
|contexts, period, and so that you could not, for example, 
|say,

|char *i;
|int j;
|scanf("%d",&j);
|i = (char *) j;

|and end up with something other than a null pointer if you input 
|0 to the scanf, then there would be a lot less discussion in comp.lang.c.

What in the world are you going to do with a pointer value that you read
from a file?  The only useful information you could get would be to note
whether it was zero, which you hope to equate to a nil pointer.  This
purpose might be better served by using a flag instead: it doesn't purport
to carry more information that it really has, and it doesn't rely on
nil pointers being all-bits-zero.
-- 

Steve Clamage, TauMetric Corp, steve at taumet.com



More information about the Comp.lang.c mailing list