NULL is used in several ways.
As a pointer to address zero. NULL is defined in several ANSI headers as
the symbolic constant
(void *)0. Zero is often returned
from functions that normaly return a pointer to signal an error. It is therefore
conveniant to compare a function return code with NULL to catch errors.
if ((fp=fopen("/etc/hosts","r") == NULL)
To mark the end of a character string. A null character is used to terminate
the string. For example if you coded:
char * text="abc";
You will actually reserve FOUR bytes containing in ASCII hex.
61 62 63 00
a b c \0
The null at the end can be coded by using the
escape sequence '\0'.
\0 is actually an octal escape sequence,
strictly speeking it should be written as \000
The following headers define NULL.