显示各种类型的数据大小 显示
程序员成长之旅 · 程序员成长之旅/C语言/自己写的源码 · 231 字
C Primer Plus 书上内容
//* typesize.c -- 打印类型大小 */
#include<stdio.h>
int main(void)
{
/* C99为类型大小提供%zd转换说明 */
printf("Type int has a size of %zd bytes.\n",
sizeof(int));
printf("Type char has a size of %zd bytes.\n",
sizeof(char));//char 大小一定是1字节
printf("Type long has a size of %zd bytes.\n",
sizeof(long));
printf("Type long long has a size of %zd bytes.\n",
sizeof(long long int));
printf("Type double has a size of %zd bytes.\n",
sizeof(double));
printf("Type long double has a size of %zd bytes.\n",
sizeof(long double));
return 0;
}
运行结果:
*在VS2017环境下测试
32位:

64位:
