I understand well how postfix and prefix increments/decrements work. But my question is, in a for loop, which is more efficient or faster, and which is more commonly used and why?
Prefix?
for(i = 0; i < 3; ++i) {...}
Or postfix?
for(i = 0; i < 3; i++) {...}
In this particular case, none is actually more efficient than the other. I would expect ++i
to be more commonly used, because that's what would be more efficient for other kinds of iterations, like iterator objects.