[英]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.