C-language operators and their precedence summary table formulas

Source: Internet
Author: User

C-language operators and their precedence summary table formulas
Round down ARROW one comma
Extraordinary increase and decrease the length of strong needles
Three multiplication, four plus minus, five shifts.
Don't forget the fish, it's in Sheng Fan's cook.
Small lamps, headlights, lamps and lanterns.
Dad feed the fish, uncle doubts, naked chickens are also confused
13 Aunt, 14 father, XV tease, pocket to low
"Round down arrow one comma" refers to the 15th level operator. Where the circle refers to the operator (), which refers to the subscript operator [], the arrow refers to the struct member operator-&gt, and comma refers to the struct member operator,
"Extraordinary increase or decrease of strong and strong needle length" refers to the 14th level operator. This is not a logical operator!, refers to the bitwise negation operator ~, increment or decrement refers to the self-increment and decrement operator + + and--, rich refers to the minus operator-, strongly refers to the type conversion operator (type), the needle refers to the pointer operator *, refers to the address operator & Long refers to the length operator sizeof
"Three multiplication, four plus minus, five shifts" refers to the operator from level 13th to level 11th. 345 of them have no practical significance, just a level of distinction. You can also imagine that the third finger is the 13th level operator. Multiplication refers to the multiplication operator * and division operator/, plus minus refers to the addition operator + and subtraction operator-, shift refers to the left shift operator << and right shift operator >>
"Do not forget the fish, it is in Sheng Fan's cook" refers to the remainder operator%, which is located in the cook of Sheng Fan, which refers to the multiplication operator, the division operator together.
"Small lamp headlights" refers to the operator from level 10th to level 9th. The small lamp headlamps refers to the relational operators <, <=, > and >=, the lamp refers to the equals operator = =, not equal to the operator! =
"Dad feeds the fish, the uncle doubts, the naked chicken also doubts" refers to the 8th level to the 4th level operator. Among them, the father to feed the fish refers to the 8th level of the bitwise AND operator & and uncle doubts refers to the bitwise XOR of the 7th level or operator ^ and level 6th of the bit or operator | |, naked chickens are also confused about the class 5th, 4th logic and operators && and logic or operators | |
"13 aunt, 14 father, a tease, pocket to Low" refers to the 3rd level to the 1th operator. Among them, 13 aunt refers to the condition operator?: (three has double meaning, that is, refers to?: The priority level is three, and its operator type is also Trinocular,? Is not aunt is puzzled?), 14 The parent's 14 has no practical meaning, the parent refers to the assignment operator =, + =,-=, *=,/=,%=, >>=, <<=, &=, ^=, and |=, and XV refers to the 1th-level operator, The pocket-to-low refers to the 15-level operator, which ends.
Appendix: C-Language operators and precedence

Precedence operator meaning operator type Union direction
15 () parenthesis Monocular 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
+ + self-increment operator
--Self-subtraction operator
-Minus sign operator
(type) type conversion operator
* pointer operator
& Address Operators
Sizeof length operator
13 * multiplication operator binocular from left to right
/Division Operator
% seek remainder operator
12 + addition operator
-Subtraction operator
One << left shift operators
>> Right Shift operator
<, <=, >, >= 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? : Conditional operation Fusan from right to left
2 =, + =,-=, *=,
/=,%=, >>=,
<<=, &=, ^=, |= assignment operator Binocular
1, comma operator binocular from left to right
② bracket member first;  The parentheses operator [] () member operator.        All monocular second; All monocular operators such as + + + (positive)-(negative) pointer operation *&

Multiplication Yozo, plus minus four; This "remainder" refers to the residual operation that is%
Shift five, relationship six; Shift operators:<< >>, Relationships:> < >= <=, etc.
Equal to (and) unequal row seventh; That's = = =!
Bits and Xor and bits or; These are bitwise operations: Bits and (&) XOR (^) bits or (|)
"Three points of the world" eighty or ninety;
Logical OR heel//logical operators: | | and &&
12 and 11;  Note Order: Priority (| |) Bottom-to-priority (&&)
Conditions above assignment,//three mesh operator precedence to 13-bit only than assignment operator and "," high//need to be aware that the assignment operator is many!
Lowest comma operation level! The comma operator has the lowest precedence
Because the C language operator precedence is not exactly the same as C + + (mainly by adding several operators), this formula is not fully practical for C + +. But should be compatible, you can compare their differences should be able to quickly grasp the priority of C + +!

((*strdest++=*strsrc++)! = ' + '); :
Emphasis: + + increment operator precedence higher than *
1.*strdest++ equivalent to * (strdest++)
2. Since it is post-increment, the order of execution is:
*strdest=*strsrc
strdest++ strsrc++//The level sequence is unknown
Compare *strdest with ' +/', that is, the value of the entire expression is the comparison between *strdest and ' + '
It is worth noting that for an assignment expression, the value of the expression itself is equal to the value of the left sub-expression.
Through this in-depth analysis, we know that this expression accomplishes the following functions:
1. For pointer strdest, STRSRC assigns the value of the memory space referred to by the STRSRC to the memory space referred to by strdest.
2. Determine if the value of the memory space referred to by the assigned strdest is equal to 0.
3. For pointer strdest,strsrc, their values are added 1 respectively, which means the next element.
That is, the expression implements the following three functions:
1. For pointer strdest, STRSRC assigns the value of the memory space referred to by the STRSRC to the memory space referred to by strdest.
2. Determine whether the value of the memory space referred to by the strdest after the assignment is equal to 0.
3. For pointer strdest,strsrc, their values are added 1 respectively, which means the next element.

Http://c.biancheng.net/cpp/html/1386.html

C-language operators and their precedence summary table formulas

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.