Operator precedence rules in C

Operator precedence rules

 

Operators

Order of evaluation

Remarks

[] ( ) ->

Left to right

Array subscript, function call

− + sizeof( ) ! ++ −−

 

 

& * ~ (cast)

Right to left

Unary

* / %

Left to right

Binary Multiplicative

+ -

Left to right

Binary Additive

>> <<

Left to right

Shift operators

< <= > >=

Left to right

Relational operators

== !=

Left to right

Equality operators

&

Left to right

Bitwise AND operator

^

Left to right

Bitwise XOR operator

|

Left to right

Bitwise OR operator

&&

Left to right

Logical And operator

||

Left to right

Logical Or operator

?:

Left to right

Conditional operator

= += -= *= /= %=

 

 

&= -= |= <<= >>=

Right to left

Assignment

,

Right to left

Comma

原文地址:https://www.cnblogs.com/lake-of-embedded-system/p/3504250.html