C language-Summary of priority and associativity

Source: Internet
Author: User

Priority:

 

The C language has a total of 15 priorities:

 

Parentheses: (), []; member operators:-> ,.

Second for all single object; // All single object operators, such as ++ -- + (positive)-(negative) pointer operations *&

Multiply the remainder three and add or subtract four; // This "remainder" refers to the remainder operation, that is, %

Shift 5, relation 6; // shift operator: <>>, relation: ><>=
Equals (and) to the seventh row; // that is, =! =

Bitwise AND exclusive or bitwise OR, // these operations are bitwise operations: bitwise AND (&) exclusive or (^) bitwise OR (|)

"Three parts of the World" 80 or 90;

Logical or sum, 12th and 11th; // OPERATOR: | and &&

The condition is higher than the value assignment;

The lowest comma operation level; // The lowest comma operator priority

 

Since the operator priority of C language is not exactly the same as that of C ++ (mainly adding several operators), this phrase cannot be fully used in C ++. but it should be compatible. You can compare their differences and quickly grasp the priority of C ++!

 

Combination:

If the operator has the same priority, you have to look at the combination, which is summarized as follows:

 

 From right to left (3 in total): single object operator, conditional operator, and value assignment operator.

The other operators (that is, the Union direction) are from 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.