The C operator precedence chart looks like this:
Why is post increment/decrement first on the list but *p++ results in dereferencing a pointer first and then incrementing adress it points to?
*p++
parses as *(p++)
.
the value of p++
is p
(and the side effect is incrementing p
), so the value of *p++
is the same value as *p
.
Except for the side-effect, *p
and *p++
are identical.
The exact same thing happens with integer:
int n = 6;
printf("%d\n", 7 * n);
printf("%d\n", 7 * n++); // except for the side-effect same value as above