Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
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.
Finding Size of a Void PointerÂ
To find the size of a void pointer, you can use the sizeof() operator that accepts a data type, variable name, or any value and returns its size. In this case, you need to pass the name of the void pointer.
Syntax
Following is the basic syntax of void pointer in C/C++:
sizeof(ptr)
Example Demonstrating Size of Void Pointer
In this example, we find out the size of void pointer using sizeof() function.
#include <stdio.h>
int main() {
void *ptr;
printf("The size of pointer value : %zu", sizeof(ptr));
return 0;
}
Output
The above program produces the following result:
The size of pointer value : 8
Explanation,
In the above example, a void type pointer variable is created using sizeof() function, the size of void pointer is found out.
