Priority of + + and * in C language

Source: Internet
Author: User

I took it for granted. The pointer budget character in C is definitely higher than + +, and later, when writing a program, it's not so sure.
In C, the precedence relationship between the self-increasing operator + + and the pointer operator * is
Left + + > * > right + +

For example, + + *i equivalent to + + (*i), pointer i corresponding to the variable +1.

*i + + is equivalent to * (i++), pointer I, which is address value +1 (in fact, add 1 variables to the address space) #include < stdio.h >

void Main () ... {
int n = 2;
int *i = &n;             *i + +; should be * (i + +);
printf ("%d", *i);
}

For example, the above program, the results of the output is not what we think of 2+1=3, but garbage data, *i++, pointer I point to the address has changed, and the previous address of the data has not changed.

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.