English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

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

The size of a null pointer varies from system to system. If the system is16bytes. If the system is2bytes. If the system is32bytes. If the system is4bytes. If the system is64bytes. If the system is8bytes.

This is an example to find the size of void pointer in C language.

Example

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

Output result

The size of pointer value: 8

In the above example, an empty type pointer variable is created and used bysizeof()The function determines the size of a null pointer.

void *ptr;
printf("The size of pointer value: %d", sizeof(ptr));