2007年4月16日 星期一

C Operator Precedence and Associativity

http://www.difranco.net/cop2220/op-prec.htm

Operator
Description Associativity

()
[]
.
-> Parentheses (grouping)
Brackets (array subscript)
Member selection via object name
Member selection via pointer left-to-right

++ --
+ -
! ~
(type)
*
&
sizeof Unary preincrement/predecrement
Unary plus/minus
Unary logical negation/bitwise complement
Unary cast (change type)
Dereference
Address
Determine size in bytes right-to-left
* / % Multiplication/division/modulus left-to-right
+ - Addition/subtraction left-to-right
<< >> Bitwise shift left, Bitwise shift right left-to-right
< <=
> >= Relational less than/less than or equal to
Relational greater than/greater than or equal to left-to-right
== != Relational is equal to/is not equal to left-to-right
& Bitwise AND left-to-right
^ Bitwise exclusive OR left-to-right
| Bitwise inclusive OR left-to-right
&& Logical AND left-to-right
|| Logical OR left-to-right
?: Ternary conditional right-to-left
=
+= -=
*= /=
%= &=
^= |=
<<= >>= Assignment
Addition/subtraction assignment
Multiplication/division assignment
Modulus/bitwise AND assignment
Bitwise exclusive/inclusive OR assignment
Bitwise shift left/right assignment right-to-left
,
Comma (separate expressions) left-to-right

1 則留言:

匿名 提到...

Thanks for sharing this link, but unfortunately it seems to be down... Does anybody have a mirror or another source? Please reply to my post if you do!

I would appreciate if a staff member here at anoty.blogspot.com could post it.

Thanks,
Jack