Duplicate possible:
why "++x || ++y && ++z" calculate "++x" firstly ? however,Operator "&&" is higher than "||"priorité de l'opérateur en C
Le programme suivant ne semble pas fonctionner comme prévu. '& &' doit avoir une précence supérieure à '||', donc la sortie réelle est confuse. Quelqu'un peut-il expliquer l'o/p s'il vous plaît?
#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;
}
La sortie réelle est la suivante: 2 1 1
TIA.
Un autre http://stackoverflow.com/questions/7212482/problem-with-operator-precedence – AnT