Operation Sequence of the printf function

Source: Internet
Author: User

 

Operation Sequence of the printf function

# I nclude <stdio. h>
Int main ()
{
Int I = 8, j = 3;
Printf ("% d/N", ++ I, I, I ++, I );
Printf ("(J ++) * (++ J) + (j --) * (-- J) = % d J = % d ", (J ++) * (++ J) + (j --) * (-- J ), j, ++ J, J );
Getch ();
Return 0;

}

 

Enter the aboveCode, You can know: In the comma-separated "," formula is calculated from right to left, first calculate the rightmost

J. Calculate ++ J, calculate the number on the right, and then calculate the second J. Finally, (J ++) * (++ J) + (j --) * (-- J );

In (j ++) * (++ J) + (j --) * (-- J), the operations are performed from left to right. The calculation is performed first (J ++) from (++ J) to (j ++) * (++ J) to (j --)

To (-- J), to (j --) * (-- J), is the addition operation in the middle.

Principle:
Because they are the parameters of printf, the function printf reads from left to right, then puts the first read to the bottom of the stack, and the last read to the top of the stack. The processing starts from the top of the stack, all the results we see are processed from the 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.