Hello to All,
I am new to programming & learning, I am trying( in wrong way)to print the content of pointer to int.
what i have done, i have assigned pnum the starting address of const int 345;( which goes with warning in gcc compiler & need (int*) cast in VSexpress edition.
later on I pass pnum to C-legendary printf(), strangely it prints the number 345 , instead of address.
i have consulted many on-line docs & K&R C book , but could not understand what is happening beneath.
Code:
main() {
int *pnum;
pnum = 345; // Assign pnum start address of const int 345
printf("\n value stored in pnum %d " , pnum); // it prints 345 instead of address.
// printf("\n Value stored in *pnum %d" ,*pnum); uncomment to crash the program.
return 0;
}
Theoretically it should print the address not content. forum members are requested to enlighten new learner like me
Thanks
Adi