Jump to content

Operator precedence in C

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by 80.58.55.172 (talk) at 12:39, 17 April 2005 (create the page. I cant make the border show up. The cells should center-aligned). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
C operator precedence table

OperatorDescriptionAssociativity ()
[]
.
->
Parentheses (grouping)
Brackets (array subscript)
ember 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 (XOR) 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