int a = 1,b = 2,c = 3; a = b == c输出为1,但在printf()中输出不是我的期望。为什么会这样?
我试图改变几种书写方式,似乎总有输出总是不同的。
int a = 1, b = 2, c = 3;
printf("%d,%d,%d,%d\n", a = b = c, a = b == c, a == (b = c), a == (b == c));
//vs2019 out :3,3,1,0
//gcc out :3,3,0,0
int a = 1, b = 2, c = 3;
a = b = c;
printf("%d,%d,%d\n", a = b == c, a == (b = c), a == (b == c));
//vs2019 out :1,0,1
int a = 1, b = 2, c = 3;
printf("%d,%d,%d\n",a = b == c, a == (b = c), a == (b == c));
//vs2019 out :1,0,1
我希望输出为1,但是代码段2为3。