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


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));

karthikeya Boyini
karthikeya Boyini

I love programming (: That's all I know

Updated on: 26-Jun-2020

6K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements