Code:Operators Associativity () [] -> . left to right ! ~ ++ -- + - * (type) sizeof right to left * / % left to right + - left to right
I was reading the 2nd chapter of K&R's The C programming language and came up accross this table.What i mentioned above is just a part of it.
I was confused by the 2nd ,3rd and 4th rows. As we can see in the second we have +-*
and in the 3rd we have * and in the 4th +-. Why the same thing is shown in different rows? Why is their Associativity different ?
And what is meant by associativity.Is it that if the same operator is available in the same expression ?
As i continued reading i came upon
x = f() + g();
where it said that the result is unpredictable.But wouldnt it go from left to right ? It should first it calculates the f() and then g() ... ?
Im confused with all of these ... Any help would be great .Thank you