What is the size of void pointer in C/C++?

CC++Server Side Programming

The size of void pointer varies system to system. If the system is 16-bit, size of void pointer is 2 bytes. If the system is 32-bit, size of void pointer is 4 bytes. If the system is 64-bit, size of void pointer is 8 bytes.

Here is an example to find the size of void pointer in C language,

Example

 Live Demo

#include <stdio.h>
int main() {
   void *ptr;
   printf("The size of pointer value : %d", sizeof(ptr));
   return 0;
}

Output

The size of pointer value : 8

In the above example, a void type pointer variable is created and by using sizeof() function, the size of void pointer is found out.

void *ptr;
printf("The size of pointer value : %d", sizeof(ptr));
raja
Published on 05-Nov-2018 11:57:02
Advertisements