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.