When I first learned C, it was easy to mix up. Later I wrote an example to explain it in depth. Finally, I understood the difference.
First, when the prefix ++ appears before the variable, the value before the variable calculation will increase by 1, and the variable with the suffix ++ needs to increase its own value after calculation.
Second, the ++ symbol can only be used before and after variables.
The following is a detailed example to learn more about it:
# Include <stdio. h>
Int main ()
{
Int sum = 0, I = 0;
Int J = 0, H = 0;
Int f = 0;
Printf ("The I is % d \ n", I ++ );
Sum = I ++ I;
Printf ("The I is % d \ n", I );
Printf ("the sum is % d \ n", sum );
Sum = ++ J;
Printf ("the J is % d \ n", J );
Printf ("the sum is % d \ n", sum );
Sum = H ++ h;
Printf ("the H is % d \ n", H );
Printf ("the sum is % d \ n", sum );
Sum = H ++ h;
Printf ("the H is % d \ n", H );
Printf ("the sum is % d \ n", sum );
Printf ("the F is % d \ n", ++ F );
H = ++ F;
Printf ("the H is % d \ n", H );
// H ++;
Printf ("the H is % d \ n", H ++ );
Printf ("the H is % d \ n", H = (H ++ ));
Return 0;
}
The running result is as follows: