int,long int,short int的宽度是随着编译器的情况而不同的。
根据ANSI/ISO制订的的原则如下:
1 sizeof(short int)<=sizeof(int)
2 sizeof(int)<=sizeof(long int)
3 short int至少应为16位(2字节)
4 long int至少应为32位。
| 编译器 | 16位编译器 | 32位编译器 | 64位编译器 |
| char | 1 | 1 | 1 |
| char*(指针变量) | 2 | 4 | 8 |
| short int | 2 | 2 | 2 |
| int | 2 | 4 | 4 |
| long int | 4 | 4 | 8 |
| unsigned int | 2 | 4 | 4 |
| long long | 8 | 8 | 8 |
| float | 4 | 4 | 4 |
| double | 8 | 8 | 8 |
| unsigned long | 4 | 4 | 8 |
| unsigned char | 1 | 1 | 1 |
| bool | 1 | 1 | 1 |
unsigned 是指无符号类型
浙公网安备 33010602011771号