C語言中各種資料型別的大小
C語言
1.幾條規則
(1)char型別一般是8bit,但ANSI C裡沒有硬性規定其長度,某些嵌入式編譯器可能是16bit
(2)short和long型別的長度不相同
(3)int型別通常同具體機器的物理字長相同
(4)short通常是16bits, int通常是16bits or 32bits每種編譯器可以根據硬體的不同自由確定, 但是short和int必須最少是16bits, 而long型別必須最少是32bits, 並且short必須比int和long型別要短。
2.32位機上型別長度
size of char: 1
size of int: 4
size of long:4
size of float:4
size of long long:8
size of double:8
size of long double:12
size of char * :4
3.64位機上型別長度
size of char:1
size of int:4
size of long :8
size of float :4
size of long long:8
size of double:8
size of long double:16
size of char * :8
4.16位機型別長度
char: 1
int: 2
long:4
unsigned int:2
unsigned short:2
unsigned long:4
float:4
size of char * :4