#include <stdio.h>
int main()
{
int x = 1;
short int i = 2;
float f = 3;
if (sizeof((x == 2) ? f : i) == sizeof(float))
printf("float\n");
else if (sizeof((x == 2) ? f : i) == sizeof(short int))
printf("short int\n");
}
Output is "float". So i don't understand why sizeof((x==2)?f:i)
always return 4
.
I think declaration is missing variable at (x==2)?f:i;
But it always returns 4(sizeof(f))
.
Can you help me! This is the first programming language I learn. I know this question very stupid but with me very hard. Thanks for spends your time:) Have a good day ;)
And the first time I try to use Stackoverflow, maybe have some mistakes. Hope you forgive me