Which is executed quickly?
Answer: C
Correct answer: Both
On any modern compiler ++p and p++ compile to the same machine code when the result is discarded, as in a for loop’s third clause - the optimiser sees that the old value is unused. The historical preference for ++p matters for C++ iterators, where p++ must copy the object before incrementing it.
Please log in or register to report this question.