1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
#include <iostream> #include <string> #include <algorithm> main () { string a = "Hallo,bla: foo!"; int x = 0; string b; cout << count (a.begin (), a.end (), 'l') << endl; x = a.find_first_of (","); b.resize (x + 1); a.copy (b.begin (), x); cout << b << endl; a.erase (0, x + 1); cout << b << endl; cout << a << endl; }