I am learning C programming language these days. I have a question about pointer.
The textbook said pointer stores memory address, and using printf("%p",pointer)
we can show where this pointer points in our memory.
But every pointer alse has a type, like int *pointer
, long *p
and so on. int *pointer
means "p is a pointer to int".
My question if we write
int *p,i;
p=&i;
*p=99;
if the pointer only contains the address information, how could the programme know how many digits should be used for storing integer 99? Because an integer could be 16 bits int
or 32 bits long
.
So I was wondering if an int pointer in memory not only stores address information, but also stores the type information?