Am a absolute beginner in C programming.
My doubt is
int a=10;
int *b;
what is the difference between
b=a; and b=&a; ?
Am a absolute beginner in C programming.
My doubt is
int a=10;
int *b;
what is the difference between
b=a; and b=&a; ?
b=a is a assignment statement which assigns the value of a to b. In the other case b=&a is a pointer notation a=10 is stored in a particular location and the address of the location is assigned to b.In other words b points the location of a.
b=a … will result in b pointing to the memory location of 10 ( which is the value of a ), value of *b will have some undefined value.
b=&a … will result in b pointing to the location of a .
hence *b will have the value 10 .