Reputation: 706
I've recently been reading Pointers on C book of Kenneth A. Reek. The book has a really nice table of C operators and their precedence levels. However, when I checked other resources to make sure information provided in the book is correct and up-to-date, I've seen there are varying information around. I'll provide precise examples to show what I exactly mean.
The book provides a table where the function call operator ()
has the highest precedence. Postfix increment and decrement operators are coming after. I've checked other resources to validate the information. I've checked this resource and this resource and this resource. The precedence information provided in these resources match with what is explained in Pointer on C book. Problem starts with precedence table in cppreference because it has different precedence rules than other resources.
So am I missing something?
Upvotes: 2
Views: 92
Reputation: 134336
As already mentioned in the linked resource
Operators that are in the same cell (there may be several rows of operators listed in a cell) are evaluated with the same precedence, in the given direction. For example, the expression
a=b=c
is parsed asa=(b=c)
, and not as(a=b)=c
because of right-to-left associativity.
So, the written order of operators (with same precedence) in any article does not matter much, the associativity (as present in the actual statement to be evaluated) is important.
Upvotes: 6