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 statement
*intAPtr++ = *intBPtr++;
is parsed as
*(intAPtr++) = *(intBPtr++);
and breaks down as follows:
intBPtr
(3) is assigned to the location pointed to by intAPtr
(intgA[0]
); intAPtr
and intBPtr
are incremented.The exact order in which these things happen is unspecified; you cannot rely on intBPtr
being incremented after intAPtr
or vice-versa, nor can you rely on the assignment occuring before the increments, etc.
So by the time this is all done, intgA[0] == 3
and intAPtr == &intgA[1]
and intBPtr == &intgB[1]
.
The expression a++
evaluates to the value of a
before the increment.