C语言编程输出不同整型数据类型在内存中占的字节数
使用sizeof(),sizeof()是保留字,它的作用是求某类型或某变量类型的字节数
代码如下:
#include <stdio.h>
int main()
{
int a = sizeof(short);
int b = sizeof(int);
int c = sizeof(long);
int d = sizeof(long long);
printf("The size of short is %d bytes.\n",a);
printf("The size of int is %d bytes.\n",b);
printf("The size of long is %d bytes.\n",c);
printf("The size of long long is %d bytes.\n",d);
return 0;
}