[英]If my computer is a 32 bit system, it has a 32 bit address right? But when I print any memory address in C why do I get an address <32bit?
例如
printf("%u",&a);
给我输出
65524
这是一个16位地址。
您还可以通过检查任何指针的大小而不是测试变量的地址来简单地回答有关地址大小的假设:
printf("%zu\n", sizeof(int*));
printf("%zu\n", sizeof(float*));
假设所有系统中的一个字节等于八位,则可以看到地址的大小。
请参阅此帖子
要找到(大多数)当前常见系统的最高地址,请执行以下操作:
#include <stdint.h>
#include <stdio.h>
int main(void)
{
uintptr_t uip = (uintptr_t) -1;
void * vp = (void*) uip;
printf("%p\n", vp);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.