Hello,
can someone tell me why or what of dereferenceing a pointer variable, which has the value NULL? I saw this in the book I was reading and could not find what it meant by that.
Hello,
can someone tell me why or what of dereferenceing a pointer variable, which has the value NULL? I saw this in the book I was reading and could not find what it meant by that.
Dereferencing a NULL pointer results in a segmentation violation. It's not something you want to happen. Run this and see how a segv occurs on your system:
-PreludeCode:#include <stdio.h> int main ( void ) { int *p = NULL; *p = 10; return 0; }
My best code is written with the delete key.
A NULL pointer is a pointer that points to... "nothing". (NULL is defined as 0, or (void*)0 ).
Dereferencing a pointer means using the asterisk to get the value it points to.
Sorry for using cout... as that's C++.. but you get the pictureCode:// ... int *pointer; int a = 7; pointer = &a; cout << *pointer << endl; // dereferences pointer and outputs 7
null pointing to zero is a compiler specific thingOriginally posted by rmullen3
A NULL pointer is a pointer that points to... "nothing". (NULL is defined as 0, or (void*)0 ).
Dereferencing a pointer means using the asterisk to get the value it points to.
Sorry for using cout... as that's C++.. but you get the pictureCode:// ... int *pointer; int a = 7; pointer = &a; cout << *pointer << endl; // dereferences pointer and outputs 7
hello, internet!
Thanks, Prelude, the program "vomitted".
(Like you knew it wouldn't!)
The 'type' is undefined, but may be re-defined later. Sans that, get the "barf bags" out!
-Skipper
"When the only tool you own is a hammer, every problem begins to resemble a nail." Abraham Maslow