This question is a very basic, but I have not known the question, is the classmate asked after only then knew, long knowledge.
It is important to note that the printf function is calculated from right to left and output from left to right.
The distance is as follows:
#include <stdio.h>Main () { int i=8; printf%d,%d,%d,%d\n", I,--i,i,i--); }
The output of this program is: 7, 7, 8, 8. The reason is thatwhen i++,i--in the printf () function, thevalue of i is refreshed after the printf () function, so in the printf () function,i++,i-- The value of I is not affected temporarily, and ++i 、--I will have an effect.
Actually here is related to the rules of the operation of printf problem, is to first into the stack and then out of the stack, and then output. Specific as follows.
For the parameters in the printf function, enter the stack in the order of the stack, and then into the stack to the bottom of the stack, after the stack to the top of the stack, after the completion of the calculation, starting from the top of the stack, the stack is the right parameter in the printf function, and then the stack is calculated, then the following elements, The first element in the printf function becomes the last calculated element and then outputs the result of the calculation in the right-to-left order, so the result of the above example is as follows.
Take this record for learning!
Input and output problems of printf functions in C language