From page 123 of The C Programming Language by K&R:
(p++)->x increments p after accessing x. (This last set of parentheses is unnecessary. Why?)
Why is it unnecessary considering that ->
binds stronger than ++
?
EDIT: Contrast the given expression with ++p->x
, the latter is evaluated as ++(p->x)
which would increment x
, not p
. So in this case parentheses are necessary and we must write (++p)->x
if we want to increment p
.
The only other possible interpretation is:
p++(->x)
and that doesn't mean anything. It's not even valid. The only possible way to interpret this in a valid way is (p++)->x
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With