prev up next   top/contents search

comp.lang.c FAQ list · Question 5.13

Q: This is strange. NULL is guaranteed to be 0, but the null pointer is not?


A: When the term ``null'' or ``NULL'' is casually used, one of several things may be meant:

  1. The conceptual null pointer, the abstract language concept defined in question 5.1. It is implemented with...
  2. The internal (or run-time) representation of a null pointer, which may or may not be all-bits-0 and which may be different for different pointer types. The actual values should be of concern only to compiler writers. Authors of C programs never see them, since they use...
  3. The null pointer constant, which is a constant integer 0 [footnote] (see question 5.2). It is often hidden behind...
  4. The NULL macro, which is #defined to be 0 (see question 5.4). Finally, as red herrings, we have...
  5. The ASCII null character (NUL), which does have all bits zero, but has no necessary relation to the null pointer except in name; and...
  6. The ``null string,'' which is another name for the empty string (""). Using the term ``null string'' can be confusing in C, because an empty string involves a null ('\0') character, but not a null pointer, which brings us full circle...

In other words, to paraphrase the White Knight's description of his song in Through the Looking-Glass, the name of the null pointer is ``0'', but the name of the null pointer is called ``NULL'' (and we're not sure what the null pointer is).

This document uses the phrase ``null pointer'' (in lower case) for sense 1, the token ``0'' or the phrase ``null pointer constant'' for sense 3, and the capitalized word ``NULL'' for sense 4.[footnote]

Additional links: mnemonic device

References: H&S Sec. 1.3 p. 325
Through the Looking-Glass, chapter VIII.


prev up next   contents search
about this FAQ list   about eskimo   search   feedback   copyright

Hosted by Eskimo North