Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with precedence and ++ and * unary operators in C

My question is not long, but it's puzzling for me. I'm one of those people who (and I think rightfully so) want to know every single rule of the languages they learn. I want to know why the language does what it does.

So, why does ++*i increment the value of *i, rather than the i pointer? The preincrement operator has a higher precedence than the indirection operator. It seems like a common sense thing, but again, I must know exactly why. Please provide references if you can.

like image 837
Subsentient Avatar asked Nov 21 '25 11:11

Subsentient


1 Answers

It cannot be parsed as *(++i), can it?

By the way, * and prefix ++ have the same precedence, and right-to-left associativity.

like image 64
nullptr Avatar answered Nov 24 '25 01:11

nullptr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!