What would be the size of pointer in c programming language?
Answer:
Answer:
Size of any type of pointer in c is independent of data type which is pointer is pointing i.e. size of all type of pointer (near) in c is two byte either it is char pointer, double pointer, function pointer or null pointer. Void pointer is not exception of this rule and size of void pointer is also two byte.
4 comments:
size of pointer depends on the compiler, whether it is using 16bit or 32bit.
In gcc it is 4bytes, In tc it is 2bytes.
Its machine dependent
The size of pointer is 2 bytes on 16 bit platform
The size of pointer is 4 bytes on 32 bit platform
The size of pointer is 8 bytes on 64 bit platform
Your old tc compiler run in 16bit mode in dos so ptr size =16 bit
while gcc run in 32 bit environment so its 32 bit
But in my gcc compiler the,
sizeof(void);
prints 1 as the answer.!
What might be the reason for this ?!
void pointer which is capable to store any kinds of pointer value
void *p;
int i;
char c;
p = &i;
or
c = &c;
both are write in case of void pointer
NRIPEDRA TRIVEDI
Post a Comment