Diary of C-operator precedence and binding direction

Source: Internet
Author: User
Tags arithmetic operators


#: Equal priority operators, the order of operations is determined by the binding direction; different precedence operators, the order of operations from high to low priority.
The union direction is mostly left-to-right, but the "single-item" condition "assignment" operator is executed from right to left.
Elementary operator () [].
            |
single-Mesh operator! ~ + +---"minus" (type) * "pointer" & sizeof
            |
arithmetic operators * "multiplication"/% +->> <<
            |
relational operators < <= > >= = = =! = & |
            |
Logical Operators | | &&
            |
conditional operator?:
            |
assignment operator = + = = *=/=%= >>= <<= &=
            |
comma operator,


Cases:

<1>*p++,* and + + a rank, right-to-left, executes address +1 first, and removes the corresponding value at execution.
<2>* (p++) and * (++P), the former is the first operation of p after the address plus 1, the latter is the address first plus 1 after the operation.
<3> (*p) + +, first find the current p corresponding variable value, and then the variable from 1, such as P=a, (*p) + + = a[0]+1.
<4>while ((*to++ = *from++)! = ' + ') assigns *from to *to first, then to and from plus 1, and finally determines if *to is ' not ', not continuing assignment
     

Diary of C-operator precedence and binding direction

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.