#include <iostream>
#include <cassert>
#include <list>
#include <string>
#include <algorithm> // for find
using namespace std;
int main()
{
string s("remembering");
list<char> list1(s.begin(), s.end());
list<char>::iterator j;
j = find(list1.begin(), list1.end(), 'i');
list1.erase(j++);
list<char>::iterator i;
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << " ";
cout << "\n\n\n";
// j now points to the 'n':
list1.erase(j++);
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << " ";
cout << "\n\n\n";
// j now points to the 'g':
list1.erase(j++);
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << " ";
cout << "\n\n\n";
list1.erase(list1.begin());
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << " ";
cout << "\n\n\n";
list1.erase(list1.begin());
for (i = list1.begin(); i != list1.end(); ++i)
cout << *i << " ";
cout << "\n\n\n";
return 0;
}
r e m e m b e r n g
r e m e m b e r g
r e m e m b e r
e m e m b e r
m e m b e r