【发布时间】:2021-05-05 01:08:27
【问题描述】:
您好,只是想知道如果您在 if 条件中使用链式分配,最左边的变量是否会用于检查 if 条件
就像 a=b=c 一样,它的 a 最终被检查,而不是 b 或 c
#include <stdio.h>
int main()
{
int a, b, c =0;
// does this reduce to a == 100 and the variables b or c are not checked if they are == to 100 but simply assigned the value of 100 ?
if( (a = b = c = 100) == 100)
printf( "a is 100 \n");
return 0;
}
【问题讨论】:
-
没关系,可能编译器不会在汇编程序中使用变量。
标签: c if-statement chained-assignment