I cannot find the answer to this question anywhere, if anyone can help it would be greatly appreciated:
What is the effect of dereferencing a pointer variable, which has the value NULL?
I cannot find the answer to this question anywhere, if anyone can help it would be greatly appreciated:
What is the effect of dereferencing a pointer variable, which has the value NULL?
You program would simply crash
By C standards (correct me if wrong)
#define NULL ((void*)0)
By C++ standards
#define NULL 0
There's no place in your main memory with adress 0 so that's what would happen.
EDIT: a segmentation fault is when a process tries to acess memory that doesn't belong to it. Should acessing memory that doesn't exist be called the same way??
Last edited by xErath; 11-17-2004 at 07:22 PM.
Thanks to both of you
Incorrect. From 'man 7 signal':Originally Posted by xErath
It's not limited to memory that's not owned by you. Any invalid memory reference causes a segmentation fault.Code:SIGSEGV 11 Core Invalid memory reference
If you understand what you're doing, you're not learning anything.
Ah, thank you