可能重複:
why "++x || ++y && ++z" calculate "++x" firstly ? however,Operator "&&" is higher than "||"運算符優先級
下面的程序似乎並不如預期的工作。 '& &'比'||'具有更高的優先權,所以實際的輸出是令人困惑的。任何人都可以解釋o/p嗎?
#include <stdio.h>
int main(int argc, char *argv[])
{
int x;
int y;
int z;
x = y = z = 1;
x++ || ++y && z++;
printf("%d %d %d\n", x, y, z);
return 0;
}
實際輸出爲:2 1 1
TIA。
另一個http://stackoverflow.com/questions/7212482/problem-with-operator-precedence – AnT