According to the ANSI base document, The Annotated C++ Reference Manual, by Bjarne Stroustrup and Margaret Ellis,
    The following conversions may be performed wherever pointers are assigned, initialized, compared, or otherwise used: A constant expression that evaluates to zero is converted to a pointer, commonly called the null pointer. It is guaranteed that this value will produce a pointer distinguishable from a pointer to any object or function. {...}

That is, in C++, any zero integer is treated as the null pointer, if the expression is used in any context where a pointer is required. While it's theoretically possible to make a CPU that uses 0xFFFFFFFF as the 'null pointer' value, or even some bizarre value like 0xDEADBEEF, in practice, all-zero is NULL.

ANSI C++ compliant header files often define NULL this way:

    #ifndef NULL
    #ifdef __cplusplus
    #define NULL    0
    #else
    #define NULL    ((void *)0)
    #endif
    #endif
    

This highlights a difference:

  • in C, NULL is defined as ((void*)0)
  • in C++, NULL is defined as 0
  • Thus, in C++, you can say char ch = NULL; and not be ruinously gauche.

    Strictly speaking, "NULL terminator" (the title of this node), can refer to a number of things:

  • At the ends of a linked list chain, the head and tail nodes often use NULL terminators to halt further traversal.
  • At the end of a table of structured data, a recognizable terminator may be used. Often, the last static initializer uses NULL pointers or other zeroes. This is a NULL terminator.
  • At the end of a string of bytes, intended to be used as a textual string, the NUL ASCII character '\0' is appended. This is done automatically by the C or C++ compiler at the end of any double-quoted string token. Whether spelled 'NUL' or 'NULL', this is a NULL terminator.
  • At the end of a SCSI bus, a terminator circuit must be placed somewhere on the bus to avoid signal echoing. Some call this a NULL terminator, as it is attached to the bus like a SCSI device, but uses no SCSI device identifier.