#include<stdio.h>
double i;
int main()
{
(int)(float)(char) i;
printf("%d",sizeof(i));
return 0;
}
它显示输出为 8。谁能解释我为什么显示为 8。?类型转换是否对变量 i.. 有任何影响,因此输出可能是 4?
#include<stdio.h>
double i;
int main()
{
(int)(float)(char) i;
printf("%d",sizeof(i));
return 0;
}
它显示输出为 8。谁能解释我为什么显示为 8。?类型转换是否对变量 i.. 有任何影响,因此输出可能是 4?
(int)(float)(char) i;不是的定义i。它只是无用地使用价值。
#include <stdio.h>
double i;
int main(void) {
i; // use i for nothing
(int)i; // convert the value of i to integer, than use that value for nothing
(int)(float)i; // convert to float, then to int, then use for nothing
(int)(float)(char)i; // convert char, then to float, then to int, then use for nothing
printf("sizeof i is %d\n", (int)sizeof i);
char i; // define a new i (and hide the previous one) of type char
printf("sizeof i is %d\n", (int)sizeof i);
}