C language operator priority
Priority |
Operator |
Meaning |
Operation required Number of Objects |
Integration direction |
1 |
() [] -> . |
Parentheses Subscript operator Point to struct member operators Struct member operators |
|
From left to right |
2 |
! |
Logical non-Operator |
1 (Single object operator) |
From right to left |
~ |
Bitwise Inverse Operator |
++ |
Auto-increment operator |
-- |
Auto-subtraction Operator |
- |
Negative Operator |
(Type) |
Type conversion Operator |
* |
Pointer Operator |
& |
Addresses and operators |
Sizeof |
Length Operator |
3 |
* / % |
Multiplication Operator Division Operator Remainder Operator |
2 (Binary operator) |
From left to right |
4 |
+ - |
Addition Operator Subtraction Operator |
2 (Binary operator) |
From left to right |
5 |
< > |
Left Shift Operator Right Shift Operator |
2 (Binary operator) |
|
6 |
< <= > > = |
Relational operators |
2 (Binary operator) |
From left to right |
7 |
= ! = |
Equal to operator Not equal to operator |
2 (Binary operator) |
From left to right |
8 |
& |
Bitwise AND operator |
2 (Binary operator) |
From left to right |
9 |
^ |
Bitwise OR operator |
2 (Binary operator) |
From left to right |
10 |
| |
Bitwise OR operator |
2 (Binary operator) |
From left to right |
11 |
&& |
Logic and operators |
2 (Binary operator) |
From left to right |
12 |
| |
Logic or operator |
2 (Binary operator) |
From left to right |
13 |
? : |
Conditional Operators |
3 (Three-object Operation) |
From right to left |
14 |
= + = -= * = /= % = >>= <= & = ^ = | = |
Value assignment operator |
2 |
From right to left |
15 |
, |
Comma Operator |
|
From left to right |
Operator priority memory method: