基本类型
整型
整型存在六种分类
名称 | 表示 | 长度/字节 | 范围(long型长度以8记) |
---|---|---|---|
整型 | int | 4 | -2^31 至 2^31-1 |
长整型 | long | 4或8 | -2^63 至 2^63-1 |
短整型 | short | 2 | -2^15 至 2^15-1 |
无符号整型 | unsigned int | 4 | 0 至 2^32-1 |
无符号长整型 | unsigned long | 4或8 | 0 至 2^64-1 |
无符号短整型 | unsigned short | 2 | 0至 2^16-1 |
#include<stdio.h>
//简单的测试占用空间程序
int main(){
int Int = 0;
long Long = 0;
short Short = 0;
unsigned int UI = 0;
unsigned long UL = 0;
unsigned short US= 0;
long long LL = 0;
unsigned long long ULL = 0;
printf("int型的占用空间:%d\nlong型的占用空间:%d\nshort型的占用空间:%d\n",sizeof(Int),sizeof(Long),sizeof(Short));
printf("unsigned int型的占用空间:%d\nunsigned long型的占用空间:%d\nunsigned short型的占用空间:%d\n",sizeof(UI),sizeof(UL),sizeof(US));
printf("long long型的占用空间:%d\nusigned long long型的占用空间:%d",sizeof(LL),sizeof(ULL));
return 0;
}