Size of Pointer:
- Pointer variable stores address(integer) hence the size of pointer equals to integer size.
- sizeof() function can be used to display the size of each pointer type.
#include<stdio.h> int main() { char* a; short* b; float* c; double* d; printf(“char* size : %d \n”, sizeof(a)); printf(“short* size : %d \n”, sizeof(b)); printf(“float* size : %d \n”, sizeof(c)); printf(“double* size : %d \n”, sizeof(d)); return 0; } |
Pointer size varies from compiler to compiler:
Compiler | Int size | Pointer size |
16 bit | 2 bytes | 2 bytes |
32 bit | 4 bytes | 4 bytes |
64 bit | 8 bytes | 8 byte |