In C and C ++, the ++ and -- operators have both the prefix form: ++i and --i , and the suffix form: i++ and i-- . Former funds are evaluated and then used and then evaluated. Difference only makes sense when any form is used as part of an expression. Otherwise, it is a matter of preference or style (or lack thereof).
F.ex., in int i = 0; int n = ++i; int i = 0; int n = ++i; , i first increases, and then its value, now 1, is assigned n . In n = i++ value of i , another 1, is assigned n and then increases, now i == 2 .
When used as an operator, that is: i++; ++i; i++; ++i; both forms are equivalent.
source share