1. 基本数据类型位数
代码如下:
#include <stdio.h>
int main(int argc,char **argv)
{
long long a;
long long b[10];
printf("sizeof(short)=%d\n",sizeof(short));
printf("sizeof(short int)=%d\n",sizeof(short int));
printf("sizeof(int)=%d\n",sizeof(int));
printf("sizeof(long)=%d\n",sizeof(long));
printf("sizeof(long int)=%d\n",sizeof(long int));
printf("sizeof(888l)=%d\n",sizeof(888l));
printf("sizeof(888ll)=%d\n",sizeof(888ll));
printf("sizeof(888L)=%d\n",sizeof(888L));
printf("sizeof(888LL)=%d\n",sizeof(888LL));
printf("sizeof(long long)=%d\n",sizeof(long long));
printf("long long a; sizeof(a)=%d\n",sizeof(a));
printf("long long b[10]; sizeof(b)=%d\n",sizeof(b));
printf("sizeof(float)=%d\n",sizeof(float));
printf("sizeof(double)=%d\n",sizeof(double));
printf("sizeof(long double)=%d\n",sizeof(long double));
printf("sizeof(888.99)=%d\n",sizeof(888.99));
printf("sizeof(888.99f)=%d\n",sizeof(888.99f));
printf("sizeof(888.99F)=%d\n",sizeof(888.99F));
return 0;
}
输出结果如下:
sizeof(short)=2
sizeof(short int)=2
sizeof(int)=4
sizeof(long)=4
sizeof(long int)=4
sizeof(888l)=4
sizeof(888ll)=8
sizeof(888L)=4
sizeof(888LL)=8
sizeof(long long)=8
long long a; sizeof(a)=8
long long b[10]; sizeof(b)=80
sizeof(float)=4
sizeof(double)=8
sizeof(long double)=8
sizeof(888.99)=8
sizeof(888.99f)=4
sizeof(888.99F)=4