#include
int main(){
int* p=0;
p++;
printf("%u\n", p);
return 0;
}
The output is: 4
and the program runs without mistakes and warnings.
But why I couldn't run the next one?
#include
int main(){
int* p=4;
printf("%u\n", p);
return 0;
}
in other words my question would be:
How to make p=4 at one stroke?
If nobody wants to help you then you have to help yourself :-) Here:
ReplyDeletehttp://www.exforsys.com/tutorials/c-plus-plus/c-plus-plus-void-pointer-and-null-pointer.html
is a good explanation of null and void pointers. Basically, the answer on my question would be: We couldn't initialize NULL pointer to 4 because it wouldn't be a null pointer.
Here is another interesting article from WikipediA about NULL pointers. I think I learned enough about it so thank you everybody who helped me.....You are very welcome :-).