Just had a chat with a C guy today and we disagreed on the following:
int intgA[2] = { 1, 2 };
int intgB[2] = { 3, 5 };
int *intAPtr = intg
The main effect of the ++
operator is to produce the value of its operand (without having incremented it). The side effect is to increment the operand.
Even if the side effect is performed before the value produced by the main effect is used in another operation, the value produced by the main effect is the original value of the operand, not the updated value.
In *x++
, which is parsed as *(x++)
, the *
operator is applied to the value produced by the main effect, so the *
operation is the same as if *x
is evaluated. The increment happens “on the side”, outside of the main expression evaluation, so it takes no part in determining the value of *x++
.