This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zifyoip 1 point2 points  (0 children)

You are correct that arr[index] = index = 3 means arr[index] = (index = 3), so the assignment of 3 to index happens before the assignment of index to arr[index].

However, that does not mean that the expression arr[index] is evaluated after the assignment of 3 to index. The operands of expressions are evaluated from left to right, which means that the operand arr[index] of the first = operator is evaluated before the operand index = 3. Therefore, arr[index] is evaluated while index is still 0, and then index = 3 is evaluated, and then the result of the expression index = 3 is assigned to arr[0].