sizeof 整數所占記憶體空間 32bit or 64bit
用以下程式分別在32bit 和64bits編譯器底下執行
char str[] = "Hello" ;
char *p = str ;
printf("sizeof(str) = %d
", sizeof(str));
printf("sizeof(p) = %d
", sizeof(p));
printf("sizeof(short) = %d
", sizeof(short));
printf("sizeof(int) = %d
", sizeof(int));
printf("sizeof(long) = %d
", sizeof(long));
printf("sizeof(long long) = %d
", sizeof(long long));
printf("sizeof(size_t) = %d
", sizeof(size_t));
printf("sizeof(double) = %d
", sizeof(double));
printf("sizeof(long double) = %d
", sizeof(long double));
64bit
32bit
sizeof(str) = 6 //char字串
sizeof(p) = 4 //指標
sizeof(short) = 2
sizeof(int) = 4 //怕因環境影響程式,絕大多數int 64,32bit的編譯器是一樣的大小
sizeof(long) = 4
sizeof(long long) = 8
sizeof(size_t) = 4
sizeof(double) = 8
sizeof(long double) = 12 //看作long+double = 4 + 8 =12
補充
int a[10] => sizeof為40 (4*10)
64bit,32bit都是
char str[100] ; => sizeof為 1
64bit,32bit都是
指標的sizeof都是 4bytes(32) or 8bytes(64)
參考資料
http://blog.urdada.net/2008/04/18/85/
';$(".articleExtAd").append(notVIP);setTimeout(function() {$('.top-toolbar').data('top-toolbar').setAD({title: "sizeof \u6574\u6578\u6240\u5360\u8a18\u61b6\u9ad4\u7a7a\u9593 (32bit and 64bit \u6bd4\u8f03)",label_id: 166,label_name: "\u7a0b\u5f0f\u8a2d\u8a08"});}, 2000);


- 日誌
- 相簿
- 影音

facebook_phoenix's 新文章
- opts用法解析
- Android Program Architecture 架構 (Android Studio)
- sizeof 整數所占記憶體空間 (32bit and 64bit 比較)
- Python入門語法
- include 的路徑 (" 冒號 和 < 括號的區別)
- C 陣列(Array)與結構(Structure)筆記
- C 指標宣告 用法 筆記 (一)
- [C Program] typedef ,enum 用法
- [C Program] malloc ,free ,calloc, realloc , new, delete介紹
- [C Program] 指標與遞增問題
facebook_phoenix's 新回應
- 沒有新回應!
- AAA





Powered by Xuite
離婚證人