本文介紹了sizeof(some pointer) 總是等于四嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
例如:sizeof(char*)
返回 4.與 int*
、long long*
一樣,我嘗試過的一切.這有什么例外嗎?
For example:
sizeof(char*)
returns 4. As does int*
, long long*
, everything that I've tried. Are there any exceptions to this?
推薦答案
你得到的保證是 sizeof(char) == 1
.沒有其他保證,包括不保證 sizeof(int *) == sizeof(double *)
.
The guarantee you get is that sizeof(char) == 1
. There are no other guarantees, including no guarantee that sizeof(int *) == sizeof(double *)
.
實際上,指針在 16 位系統上的大小為 2(如果你能找到的話),在 32 位系統上為 4,在 64 位系統上為 8,但是依靠在給定的尺寸上.
In practice, pointers will be size 2 on a 16-bit system (if you can find one), 4 on a 32-bit system, and 8 on a 64-bit system, but there's nothing to be gained in relying on a given size.
這篇關于sizeof(some pointer) 總是等于四嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!