我有以下代码:
#include <stdio.h>
int main(void)
{
int x = 2, y = 6, z = 6;
x = y == z;
printf("%d", x);
}
输出= 1
为什么?
最佳答案
因为赋值是从右到左的,并且==的优先级大于=。
它是 x = (y == z)
y == z 为 1。
关于c - 关于x=y==z的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3600465/