C – Size of Pointer

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:

CompilerInt sizePointer size
16 bit2 bytes2 bytes
32 bit4 bytes4 bytes
64 bit8 bytes8 byte

Scroll to Top