[Note] the priority of the C Operator is prone to errors.

Source: Internet
Author: User

[Note] the priority of the C Operator is prone to errors.
C Operator priority! The names or meanings of priority operators are used in combination with directions. 1 [] array subscript array Names [constant expressions] Left to right () parentheses (expressions)/function names (parameter tables ). member selection (object) object. member name-> member selection (pointer) object pointer-> member name 2-negative sign operator-expression right to left single object operator (type) Forced type conversion (data type) expression ++ auto-increment operator ++ variable name/variable name ++ single object operator -- auto-subtraction operator -- variable name/variable name -- single object operator * value operator * pointer variable single object operator & get address operator & variable name single object Operator! Logical non-Operator! Single Object operator of expression ~ Bitwise inversion operator ~ Expression single object operator sizeof length operator sizeof (expression) 3/division expression/expression left-to-right binocular operator * multiplication expression * expression binocular operator % remainder (Modulo) integer expression/Integer expression binocular Operator 4 + addition expression + expression left-right binocular operator-subtraction expression-expression binocular operator 5 <left shift variable <expression left-right binocular operator> right shift variable> Expression binocular operator 6> greater than expression> Expression left to right binocular operator> = greater than or equal to expression> = expression binocular operator <less than expression <expression binocular operator <= less than or equal to expression <= expression binary operator 7 = equals expression = expression left to right binary operator! = Not equal to the expression! = Expression binocular operator 8 & bitwise and expression & Expression left-right binocular operator 9 ^ bitwise OR expression ^ expression left-right binocular operator 10 | bitwise OR expression | expression left-right binocular operator 10 operator 11 & logic and Expression & Expression left-to-right binary operator 12 | logic or expression | expression left-to-right binary operator 13?: Conditional operator expression 1? Expression 2: expression 3 Right to left three orders Operator 14 = assign value operator variable = expression right to left/= assign value variable after Division/= expression * = assign value variable after multiplication * = expression % = after modulo operation assign variable % = expression + = add variable + = expression-= assign variable after subtraction-= expression <= assign variable after left shift <= expression> = assign value after right shift variable >>= Expression & = bitwise AND postpaid variable & = expression ^ = bitwise OR postpaid variable ^ = expression | = bitwise OR postpaid variable | = expression 15, comma operator expression, expression ,... Operations from left to right: for operators with the same priority, the operation order is determined by the combination direction. For some error-prone priority problems, If the operators with the same priority as 1 appear at the same time, how can we determine the priority of an expression? This is a confusing place for beginners. The following table sorts out the error-prone situations: wKioL1Y-7SWC2rc4AAJHHolg3W4790.jpg priority phrase brace member 1; brace operator [] () member operator. -> all single object and second object; all single object operators, such as ++ -- + (positive)-(negative) pointer operations * & multiplication and division of three, plus and minus four; this "remainder" refers to the remainder operation, that is, % shift 5, relation 6; Shift Operator: <>>, relation: ><>=and so on (and) wait for the seventh row; that is, =! = Bitwise AND exclusive or bitwise OR; these operations are bitwise operations: bitwise AND (&) exclusive or (^) bitwise OR (|) "three minutes in the world" 80 or 90; logic or heel; logical operators: | and & 12 and 11; Note the sequence: Priority (|) is higher than the value assignment based on the priority (&) condition, the priority of the Three-object operator is 13 BITs, which is only equal to the value assignment operator and "," the highest level of comma is the lowest! Lowest comma operator priority

Related Article

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.