Operator precedence describes the order by which operators are evaluated in a certain language. In C, they are evaluated according to the following table:
Note that operator precedence applies to type declarations as well.
Also note that the binary + and - operators are at precedence four, and the + and - at level two are the unary plus and minus.
Example
Here are some examples of operator precedence cases that can be a bit tricky, try to see if you can figure out what they mean.
if(x = y == z){}
Answer
The assignment operator is almost all the way to the bottom, so the vast majority of other operators will precede it, including the comparison operator ==. So this will evaluate as:
if(x = (y == z)){}
*p[i];
Answer
Since brackets are at the topmost level of precedence, including the square bracket for index access, the array if first accessed, then it is dereferenced.
*(p[i]);
*p++;
Answer
Since the post-increment operator has higher precedence than the dereference operator, it is first incremented, then dereferenced.
*(p++);
x << y + z;
Answer
Since the binary + operator has higher precedence, y is first added to z before shifting x.