32位编译器
- char :1个字节
- short int : 2个字节
- int: 4个字节
- unsigned int : 4个字节
- float: 4个字节
- double: 8个字节
- long: 4个字节
- long long: 8个字节
- unsigned long: 4个字节
32位编译器下测试
#include <stdio.h>
void main(void)
{
char a;
int b;
unsigned int c;
short int d;
float e;
double f;
long g;
unsigned long h;
printf("Char类型所占空间:%u 字节\n", sizeof a);
printf("int类型所占空间:%u 字节\n", sizeof b);
printf("unsigned int类型所占空间:%u 字节\n", sizeof c);
printf("short int类型所占空间:%u 字节\n", sizeof d);
printf("float类型所占空间:%u 字节\n", sizeof e);
printf("double类型所占空间:%u 字节\n", sizeof f);
printf("long类型所占空间:%u 字节\n", sizeof g);
printf("unsigned long类型所占空间:%u 字节\n", sizeof h);
}
64位编译器
- char :1个字节
- short int : 2个字节
- int: 4个字节
- unsigned int : 4个字节
- float: 4个字节
- double: 8个字节
- long: 8个字节
- long long: 8个字节
- unsigned long: 8个字节