char | 字符 | 1字节 |
short | 短整型 | 2字节 |
int | 整型 | 4字节 |
long | 长整型 | 4字节 |
long long | 更长的整形 | 8字节 |
float | 单精度浮点数 | 4字节 |
double | 双精度浮点数(精度更高) | 8字节 |
//注:C语言没有字符串类型
#include<stdio.h>
int main(){
//可输出数据类型所占字节
printf("%d\n",sizeof(char)) ;
// printf("%d\n",sizeof(short) ;
printf("%d\n",sizeof(int)) ;
printf("%d\n",sizeof(long)) ;
// c语言规定
// sizeof(long) >= sizeof(int)
printf("%d\n",sizeof(long long)) ;
printf("%d\n",sizeof(float)) ;
printf("%d\n",sizeof(double)) ;
return 0 ;
}
int main(){
int age = 20; //向内存申请4个字节空间,把20放入
double price = 66.6;
return 0 ;
}