Priority of operators for C defects and traps

Source: Internet
Author: User
The operator priority is shown in the following table, which is reduced from left to right and from top to bottom.

() (Parentheses) [] (array subscript). (structure member)-> (pointer structure member) maximum limit
── ─ ┃ ↑
! (Non-logical). (bitwise inverse)-(negative) ++ (plus 1) -- (minus 1) & (variable address) │
── ─ ┃ │
* (Pointer content) type (function description) sizeof (length calculation) │
── ─ ┃ │
* (Multiplication)/(Division) % (Modulo) │
── ─ ┃ │
+ (Plus)-(minus) ┃ │
── ─ ┃ │
<(Shifted left)> (shifted right) │
── ─ ┃ │
<(Less than) <= (less than or equal to)> (greater than)> = (greater than or equal to) │
── ─ ┃ │
= (Equal )! = (Not equal to) sampled │
── ─ ┃ │
& (Bits and) bytes │
── ─ ┃ │
^ (Bitwise OR) │
── ─ ┃ │
| (Bit or) │
── ─ ┃ │
& (Logical and) │
── ─ ┃ │
| (Logical or) │
── ─ ┃ │
? :(? Expression) │
── ─ ┃ │
= + =-= (Joint Operation) │
── ─ ┃ │
, (Comma operator) the lowest limit

 

 

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////

Priority operator meaning operator type combination direction
15 () parentheses () from left to right)
[] Subscript operator
-> Pointer to struct member operators
, Struct member operators
14! Logical non-operator from right to left

~ Bitwise Inverse Operator
++ Auto-increment operator
-- Auto-subtraction Operator
-Minus sign Operator
(Type) type conversion Operator
* Pointer Operators
& Address Operators
Sizeof length Operator
13 * multiplication OPERATOR: left-to-right
/Division Operator
% Remainder Operator
12 + addition Operators
-Subtraction Operator
11 <left shift operator
> Right shift operator
10 <, <=,>,> = Relational operators
9 = equals Operator
! = Not equal to operator
8 & bitwise AND operator
7 ^ bitwise XOR or operator
6 | bitwise OR operator
5 & logic and operators
4 | logical or operator
3? : The conditional operators are displayed from the right to the left.

2 =, + =,-=, * =,
/=, % =, >>=,
<<=, & =, ^ =, | = Binary value assignment operator
1. the comma operator is left-to-right.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.