I am a complete novice to C, and during my university work I’ve come across comments in code that often refer to de-referencing a NULL pointer. I do have a background in C#, I’ve been getting by that this might be similar to a “NullReferenceException” that you get in .Net, but now I am having serious doubts.




int a, b, c; // some integers
int *pi;     // a pointer to an integer

a = 5;
pi = &a; // pi points to a
b = *pi; // b is now 5
pi = NULL;
c = *pi; // this is a NULL pointer dereference


来自: stackoverflow.com