What is Size of VOID pointer on multiple platforms?

Size of void pointer on 16 bit Platform is : 2 bytes , on 32 bit : 4 bytes and on 64 bit : 8 bytes.

The size of void* is of same size in C/C++, but, the size of void pointer is platform dependent.

On 32 bit platform Size of void* is 4 byte. In fact, any kind of pointer we consider i.e. int , char or float etc. all have same size and size could be 4 bytes or 8 bytes depend upon platform we are using i.e.32 bit or 64 bit etc.

Actually, whatever are pointer types, that store only address of the variables they point to, whatever it is int, float or char etc. so, size for all pointers would be same.

If we consider 32 bit platform, size of all pointers will be of 4 bytes size. And if it is 64 bit, it would be of 8 byte.

How to find size of void pointer?

To find a size of void pointer variables,  we can use sizeof operator in c or c++ program. On window 64 bit machine, generally, we should find 32 bit and 64 bit support.

So, if we want to check the size of void pointer in 64 bit or 32 bit platform then we need to check the project properties for platform x86(32 bit) or x64(64 bit) in visual studio IDE. Then we can see the size of void* as 4 or 8 byte depending upon configuration for 32 bit or 64 bit respectively.

int main(){

  void *a;

  printf("Size - void pointer:%d",sizeof(a));

  return 0;
}

Above program will give the size of void pointer. Same can be tested for multiple platforms to get the size.

Platform and pointer size:

Platform – 16 bit : 2 bytes

Platform – 32 bit : 4 bytes

Platform – 64 bit : 8 bytes

Related Posts