The real correction to MyBowlCut's code is to not mess around with (in other words change) the controlling loop iterator in the middle of the loop. Any code that I see doing that is always susceptible to some sort of bug.
How then do you deal with a situation where you need to manually control the iterator? Take for example deleting items from a STL list:

Code:
list<Foo>::iterator toDel;
for (list<Foo>::iterator it = myList.begin( ); i != myList.end( );)
{
  if (it->NeedsDeletion( ))
  {
    toDel = it;
    it++;
    myList.erase(toDel);
  }
  else
  {
    it->SomeMethod( );
    it++;
  }
}