C 資料型別大小

2021-09-05 18:28:15 字數 924 閱讀 2613

<

iostream

>

void

main()

輸出結果:

size of bool: 1 bytes

size of char: 1 bytes

size of unsigned char:  1 bytes

size of wchar_t: 2 bytes

size of short: 2 bytes

size of int: 4 bytes

size of unsigned int/unsigned: 4 bytes

size of size_t: 4 bytes

size of long: 4 bytes

size of unsigned long: 4 bytes 

size of float: 4 bytes

size of double: 8 bytes

size of long double: 8 bytes

truncation from const int to unsigned char, 333 will become: 77

註解:

1. wchar_t型別用於擴充套件字符集,如漢字和日語,這些字元不能用單個char表示

2. 一般,short型別為半個機器字(word)長,int型別為乙個機器字長,long型別為乙個或兩個機器字長

3. 在32位機中,int型別和long型別的字長通常是相同的

4. bool型別表示真值true和假值false,0值型別代表false,任何非0的值都代表true

5. 除bool型別外,整型可以是帶符號的(signed)也可以是無符號的(unsigned)

6. int,short,long都預設為帶符號型

7. 對於unsigned型別來說,編譯器對取值求模,取所得值

C 資料型別的大小

一 c 1.幾條規則 1 char型別一般是8bit,但ansi c裡沒有硬性規定其長度,某些嵌入式編譯器可能是16bit 2 short和long型別的長度不相同 3 int型別通常同具體機器的物理字長相同 4 short通常是16bits,int通常是16bits or 32bits每種編譯器可...

C 資料型別所佔位元組大小

對於指標型別,因為指標指向的是乙個位址,32位作業系統就是4位元組。64位作業系統那就是8位元組了。int這個型別佔作業系統乙個記憶體單元大小。早先16位作業系統乙個記憶體單元是16位,所以是2個位元組 32位系統乙個記憶體單元是是32位,所以是4位元組 64位作業系統,4位元組。整形加unsign...

c 資料型別大小及數值範圍

c 資料型別 32位windows系統 資料型別 位元組數 bool 1 char 1 short 2 int 4 long 4 long long 8 float 4 double 8 long double 8 指標型別 4 64位windows系統 資料型別 位元組數 bool 1 char ...