Priority stenographer of the C Operator

Source: Internet
Author: User

I believe that most of my friends who first learned C language had passed its operator priority. At that time, I did not forget how fast it was;

Later, I was not very concerned about it, because when I was writing code uncertain, I ensured it through brackets. This is also advocated in some programming specifications,

But sometimes when you read other people's code, you may have some uncertain points, until recently I found a decision, which is really good,

You can quickly remember all the priorities.


The statement is as follows:

Arrow 1 down the circle

Chang)

Multiplication and division, addition and subtraction, and shift

Don't forget the fish. It's in the kitchen.

Small lamps, headlight lamps, etc.

Dad is also confused about fish feeding, pig and bare chicken.

Aunt 13th, Father 14th, and fool 15th


Resolution:

The "arrow at the bottom of a circle" indicates the circle operator (), the subscript operator [], the arrow indicates the operator pointing to the struct member operator->, and the comma is also the struct member operator.


"Extraordinary increase or decrease in the length of prosperity and prosperity" does not refer to logical operators !, Where the bitwise anti operator ~, Increase or decrease refers to the auto-increment and auto-subtraction operators, ++, --, and rich refers to the minus operator -,

Strongly refers to the forced type conversion operator (type), star refers to the pointer operator *, ground refers to the address operator &, and long refers to the length operator sizeof

"Three multiplication division, four addition and subtraction, five shifts", three or five represents the operator priority, which has no practical significance, but is only used for classification. Multiplication, addition, subtraction, and shift represent Arithmetic Operators */+-<>

"Never forget the fish. It is in the cook who holds the meal" refers to the remainder operator, which is at the level of the multiplication and division operator.

The relational operator <=>==! =

"Dad fed fish, have doubts, and have doubts about the naked Rooster" respectively refer to bitwise AND &, bitwise XOR or ^. In addition, there are bitwise OR operators with a lower level. |, bare chicken is also confused about logical operator logic and & logic or |

"Aunt 13th, Father 14th, tease 15th, cover the end", refers to the conditional operator? : (Three has a double meaning. Its priority is thirteen and it is a three-object operator. Isn't it confusing ),

The fourteen-parent operator refers to the value assignment operator ===+-= * =/=%=<=> =

The 15th tease refers to the comma operator, which is the end of "OK.



Appendix operator table:


Join operator () []->.

Unary operator! ~ ++ -- +-* & (Type) sizeof from right to left

Multiplication and division */%

Addition and subtraction +-

Shift Operator <>

Relational operators <=> =

"Equal" comparison =! =

Bitwise operators &

Bit operator ^

Bitwise operator |

Logical operators &&

Logical operator |

Conditional operator? :

Value assignment operator = + =-= * =/= %=^=|=<<=>>=

Comma operator,






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.