Expressions involving the logical AND operator can be rewritten as follows:
if(expr1 && expr2 && expr3 ...)
is functionally equivalent to
if(expr1)
if(expr2)
if(expr3)
.
.
.
If expr1
fails, the remaining won't be evaluated.
If expr1
succeeds, expr2
will be evaluated and if expr2
fails, expr3
won't be evaluated.
In your case i
is zero, hence j++
won't be evaluated.
Excerpt from Section 6.5.13 C99 specifications
Unlike the bitwise binary & operator, the && operator guarantees left-to-right evaluation; there is a sequence point after
the evaluation of the first operand. If the first operand compares
equal to 0, the second operand is not evaluated.