Typically the code that I have seen uses phrases such as i++ as opposed to ++i. Recently, in a recently purchased book, I have seen the former implemented.
As I understand i++ means that the addition takes place after the line is executed and thus with the initial value of i. Furthermore, ++i means that 1 is added to i before the line is executed, thus changing altering the value of whatever i was used to calculate.
for example:
int i = 4
x = i++ * 10. x would be equal to 40. only after the line is executed does i equal 5.
However, in the code
int i = 4
x = ++i * 10., x would be equal to 50, because i takes on the value of 5 before the line is executed.
This all brings me to my conundrum. What is the difference between the following two lines of code:
for (int i = 0; i < something; i++)
{}
and
for (int i = 0; i < something; ++i)
{}
I'm going to take a guess that that final addition to i always takes place after the code inside the brackets is executed. This would lead to me believe that the two lines are identical; however, I somehow doubt this is the case. Can someone give me hand? Thank you very much.