C運算符優先級及結合性表(含C11標準)

Operator Operation Associativity Postfix operators (highest precedence)
++

Post-incrementide

Left to right
-- Post-decrement  
( ) Function call  
[ ] Array element  
-> Pointer to structure or union member  
. Structure or union member  
Unary operators
++ Pre-increment Right to left
-- Pre-decrement  
! Logical NOT  
~ Bitwise NOT  
- Unary minus  
+ Unary plus  
& Address of  
* Indirection  
sizeof Size in bytes of type  
_Alignof  [C11] Alignment requirement of type  
(type) Type cast (type conversion)  
Multiplicative operators
* Multiply Left to right
/ Divide  
% Remainder  
Additive operators
+ Add Left to right
- Subtract  
Bitwise shift operators
<< Left shift Left to right
>> Right shift  
Relational operators
< Less than Left to right
<= Less than or equal to  
> Greater than  
>= Greater than or equal to  
Equality operators
== Equal Left to right
!= Not equal  
Bitwise AND operator
& Bitwise AND Left to right
Bitwise exclusive OR operator
^ Bitwise exclusive OR Left to right
Bitwise inclusive OR operator
| Bitwise inclusive OR Left to right
Logical AND operator
&& Logical AND Left to right
Logical OR operator
|| Logical OR Left to right
Conditional operator
? : Conditional Right to left
Assignment operators
= Simple assignment Right to left
*= Compound assignment  
/= Compound assignment  
%= Compound assignment  
+= Compound assignment  
-= Compound assignment  
<<= Compound assignment  
>>= Compound assignment  
&= Compound assignment  
^= Compound assignment  
|= Compound assignment  
Comma operator (lowest precedence)
, Comma Left to right
相關文章
相關標籤/搜索