📜  运算符优先级 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:41.094000             🧑  作者: Mango

代码示例1
/* First priority (left-to-right) */
v++ v--       // increment/decrement suffix
() []         // function call / array subscripting
.  ->         // structure and union member access (trought pointer or not)
(type) {list} // Compond literal

/* priority 2 (right-to left) */
++v --v       // increment/decrement prefixe
+ -           // unary plus/minus
! ~           // logical and bitwise NOT
(type)        // type casting
* &           // dereference / adress-of
sizeof _Alignof

/* (left-to right) */
// priority 3
* / %
// priority 4
+ -
// priority 5
>> <<
// priority 6
< <= > >=
// priority 7
== !=
// priority 8
&
// priority 9
^
// priority 10
|
// priority 11
&&
// priority 12
||

// (right-to-left)
// priority 13
? :             // ternary conditional
// priority 14
= += -= *= /= %= <<= >>= &= ^= |= ~=

// (left-to-right) 
// priority 15
,