What is the difference between ++ I and I ++?
New programmers may ask what is the difference between ++ I and I ++? For the specific differences, please refer to Xiao Bian.
++ Is an auto-increment operator, and ++ I is equivalent to I = I + 1. Out of the simplicity of the language, programmers use ++ I and I ++ for auto-increment operations. The difference between the two lies in the order of order. It can be understood as follows: I ++ completes what others ask him to do before executing I = I + 1, and ++ I is to execute I = I + 1 and then finish what others want him to do. An example is as follows:
Int a, I = 3;
A = I ++ 1;
The result of a is 4. If I ++ is changed to ++ I, the result is 5. If only the ++ operator does not have other operators, the effects of the two are the same, for example, a common loop statement:
I ++;
Another case is that in the output statement printf ("% d", I ++, I), what is the result, which cannot be determined. This is because it is not executed from left to right, but depends on the compiler's choice. The results of a = I ++ I are also uncertain. You only need to remember not to use the same variable name in these two cases.
The above is the specific difference between ++ I and I ++. Remember that ++ I is used first and then assigned a value, while ++ I is used and assigned first.
Source: Network Teaching Base original address: http://www.studynb1.com/clanguage/250.html