The Null Pointer

A special value is reserved to indicate that a pointer does not refer to anything.

It is denoted by the constant 0.

This is not the integer 0.

The context in a program determines whether a 0 is interpreted as the null pointer or an integer value.

But most implementations use the address 0 to represent a null pointer.

Many programs incorrectly depend on this.

Use the symbolic constant (macro) NULL instead of 0 for the null pointer.

This is defined in stdio.h

Most C programmers use NULL because it makes programs more readable.

Index