#include <stdio.h>
int main(void){
int *ptr;
printf("the value of ptr is %p",ptr);
}
这给了我 0x7fffbd8ce900
,它只有 6 个字节。应该是8字节(64位)吗?
最佳答案
虽然指针是 64 位的,current processors actually only support 48 bits , 因此地址的高两个字节总是 0000 或(由于符号扩展)FFFF。
在未来,如果 48 位不再足够,新的处理器可以添加对 56 位或 64 位虚拟地址的支持,并且现有程序将能够利用额外的空间,因为它们已经在使用 64-位指针。
关于c - 如果一个指针的地址是 64 位,为什么它在打印时显示为 6 个字节?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11515662/