int * x;
int v = 7;
Given this code, what is the difference between
1. x = &v
, and
2. *x = v
?
I understand that
int v=7;
Let's say the address of v = 00ZXCDFCDGDD2345
int x=&v;
Here '&' means the address of and x is used to store the address *(00ZXCDFCDGDD2345)*
, and x itself stored at some location say *00254DBHJBDHDW*
.
Now if we want to access the value of v we use the pointer.
int *x=v;
In this statement '*x' is a pointer variable which points to v, means it stores the value of v but the x itself is undefined, it stores the garbage value. Hence both are different.