C/C++ 中 void 指针的大小是多少?
void 指针的大小因系统而异。如果系统是 16 位的,则 void 指针的大小为 2 个字节。如果系统是 32 位的,则 void 指针的大小为 4 个字节。如果系统是 64 位的,则 void 指针的大小为 8 个字节。
这里有一个 C 语言中查找 void 指针大小的示例:
示例
#include <stdio.h>
int main() {
void *ptr;
printf("The size of pointer value : %d", sizeof(ptr));
return 0;
}输出
The size of pointer value : 8
在上述示例中,创建了一个 void 类型指针变量,并通过使用 sizeof() 函数,找出了 void 指针的大小。
void *ptr;
printf("The size of pointer value : %d", sizeof(ptr));
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP