+ 4
Can I assign a value to a pointer?
5 odpowiedzi
+ 7
When you initialize the value, you store a value in that pointer itself (like if the star wasn't there, yeah, that's a bit confusing).
So what you store in there, has to be an address.
int n;
int *p = &n;
+ 4
The type of value you assign to a pointer is a memory address.
And by using *, you can assign a value to the place the pointer is pointing to, but the value of the pointer itself stays the address of that place.
+ 1
I can't do this : int *p = 45 ; ?? Because when I want to print the value it is pointing to I use *p