0

Possible Duplicate:
Is there a performance difference between i++ and ++i in C++?
Difference between i++ and ++i in a loop?

I know that a++ return the original value of a and then add one to a, while ++a increment a by one and return a. But I can´t see how this is different in a for loop.

Community
  • 1
  • 1
Aikanáro
  • 867
  • 3
  • 20
  • 42

1 Answers1

2

well if you are operation on an array in the for loop that is zero indexed and you use x++ then the first value to be processed will be the 0 index value however if you use ++x then the value to be processed first will be the 1 index.

In simpler terms:

x++ increments the value of variable x after processing the current statement.

++x increments the value of variable x before processing the current statement.

Dan
  • 41
  • 5