This content has been marked as final. Show 4 replies
In the while loop, you have full control on when you increment the i and when not and what you do is correct.
Doing this with the for loop always increments the i. To avoid this, you may find out that when you removeChar, you have to decrement the i, just to be incremented by the loop right after.
All this would result in more obscure code than the while loop, therefore I would not use it.
Edit: Why you remove 8 in the while loop and 5 in the for loop remains a big mystery.
Edited by: baftos on Apr 25, 2013 11:56 AM