C Operator Precedence
C Operator Precedence
[] Array subscripting
1 Structure and union
.
member access
Structure and union
-> member access through
pointer
(type){list} Compound literal(C99)
Prefix increment and Right-to-left
++ --
decrement[note 1]
+- Unary plus and minus
Logical NOT and bitwise
!~
NOT
(type) Cast
2
* Indirection (dereference)
& Address-of
sizeof Size-of[note 2]
Alignment
_Alignof
requirement(C11)
Multiplication, division, Left-to-right
3 */%
and remainder
4 +- Addition and subtraction
Bitwise left shift and right
5 << >>
shift
For relational operators <
< <=
and ≤ respectively
6
For relational operators >
> >=
and ≥ respectively
For relational = and ≠
7 == !=
respectively
8 & Bitwise AND
Bitwise XOR (exclusive
9 ^
or)
10 | Bitwise OR (inclusive or)
12 || Logical OR
Ternary conditional[note Right-to-left
13 ?:
3]
= Simple assignment
Assignment by sum and
+= -=
difference
Assignment by product,
14[note 4] *= /= %= quotient, and remainder
Assignment by bitwise left
<<= >>=
shift and right shift
Assignment by bitwise
&= ^= |=
AND, XOR, and OR
15 , Comma Left-to-right