The null pointer is a special value for a pointer, of any type, indicating an (and "the") invalid location. There is only one null pointer. Thus, 2 null pointers will compare equal. You are not supposed to dereference the null pointer, and doing so results in undefined behaviour -- most environments will cause an exception or deliver a signal to the process if you do. However, e.g. on a VAX, not only may you dereference the null pointer, you even know you'll get a "0" if you do (for any primitive datatype).
In C and C++, you get a null pointer by implicitly typecasting 0 (note well: this is a literal 0) to a pointer. This is part of the language definition. But it does not follow that the internal representation of the null pointer in memory is all zeroes!
Rather, an implementation may choose any sentinel value (as long as it can never be a valid pointer, of course), and assign that value whenever a statement like
char *p=0; is encountered. Some machines (AS/400, mainframes) may have completely different pointer formats than integer formats.
In particular, code such as
char **p = calloc(100,sizeof(int)); is not guaranteed to make
p point to an array of 100 NULL pointers! Rather,
p points to a block of 100 pointers, but that block is zero-filled rather than NULL-filled. This type of bug is particularly insiduous, as almost all compilers will represent NULLs as zeroes, so you will not find it in QA unless you have such a platform.
To add to the confusion, using a pointer in an integer context (in C) or a boolean one (in C++) returns a true value unless the pointer is NULL. This is how you actually use it: no valid pointer to an object is equal to NULL (or 0, see below), so NULL is perfect for use as a sentinel value. It is usually used to denote conditions such as "no object" or "error". For instance,
malloc() returns NULL if no memory could be allocated.
Proper C style is to use the macro
#defined in stddef.h), whereas proper C++ style is simply to use
Finally, Pascal uses
nil for the pointer sentinel value; no conversion from an integer type is provided.