The following code snippet:
int i=-3,j=2,k=0,m;
m=++i && ++j || ++k;
can be evaluated using two concepts,I believe:
1.Since ++
The &&
and ||
operators force left-to-right evaluation. So i++
is evaluated first. If the result of the expression is not 0, then the expression j++
is evaluated. If the result of i++ && j++
is not 1, then k++
is evaluated.
The &&
and ||
operators both introduce sequence points, so the side effects of the ++
operators are applied before the next expression is evaluated. Note that this is not true in general; in most circumstances, the order in which expressions are evaluated and the order in which side effects are applied is unspecified.