Dereferencing a null pointer

Download c eBook

Example

This is an example of dereferencing a NULL pointer, causing undefined behavior.

int * pointer = NULL;
int value = *pointer; /* Dereferencing happens here */

A NULL pointer is guaranteed by the C standard to compare unequal to any pointer to a valid object, and dereferencing it invokes undefined behavior.

Stats

Contributors: 4
2016-07-26
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook