So, I was writing some code and I was getting an unexpected output in one part of my program which disrupted the entire system.
I managed to extract and simplify th
From the C Standard (6.5.14 Logical OR operator)
3 The || operator shall yield 1 if either of its operands compare unequal to 0; otherwise, it yields 0. The result has type int.
This expression
++i || ++j && k
is equivalent to
++i || ( ++j && k )
and according to the quote from the Standard the expression returns integer value 1 because ++i
is not equal to zero. The subexpression ( ++j && k )
is not evaluated.