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

The size of void pointer varies from 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. This is because a pointer stores memory addresses, and the size depends on the system's addressing capability.

Syntax

To find the size of a void pointer, use the sizeof() operator:

sizeof(void*)
sizeof(pointer_variable)

Example: Finding Size of Void Pointer

The following example demonstrates how to find the size of a void pointer using the sizeof() operator −

#include <stdio.h>

int main() {
    void *ptr;
    printf("Size of void pointer: %zu bytes\n", sizeof(void*));
    printf("Size of pointer variable: %zu bytes\n", sizeof(ptr));
    printf("System architecture: %d-bit\n", (int)(sizeof(void*) * 8));
    return 0;
}

Output

Size of void pointer: 8 bytes
Size of pointer variable: 8 bytes
System architecture: 64-bit

Key Points

  • All pointer types (int*, char*, void*) have the same size on a given system.
  • The size is determined by the system's memory addressing architecture.
  • Use %zu format specifier for size_t values returned by sizeof().

Conclusion

The size of a void pointer depends on the system architecture. Modern 64-bit systems typically have 8-byte pointers, while older 32-bit systems use 4-byte pointers.

Updated on: 2026-03-15T09:55:31+05:30

9K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements