【发布时间】:2021-02-02 01:34:51
【问题描述】:
K&R c 说:&&的优先级高于||
但是为什么下面的代码,c 和d 仍然是-1:
int a, b = -1, c = -1, d = -1;
a = (b = 1) || (0, c = 0) && (1, d = 0);
【问题讨论】:
-
因为
||的右侧是short-circuited 并且从未计算过。 -
@dxiv,我使用 = 来查看评估的部分。
标签: c logical-operators operator-precedence