【发布时间】:2017-07-26 11:15:43
【问题描述】:
使用 sizeof() 打印变量的大小
#include <stdio.h>
main()
{
int a = 10,b = 20;
short int c;
short int d = sizeof(c = a+b);
int e = sizeof(c*d); //e holds the value of 4 rather than 2
double f = sizeof(e*f);
printf("d:%d\ne:%d\nf:%lf\n",d,e,f);
}
为什么 sizeof() 返回 int 的大小而不是 short int 的大小,这意味着 2 个字节?
【问题讨论】:
标签: c