C++ examples for STL:string
Erase a string with iterator
#include <iostream> #include <string> #include <cctype> #include <algorithm> #include <vector> using namespace std; int main()//from w w w. j av a 2 s. c om { string strA("This is a test. another test test test"); // Create an iterator to a string. string::iterator itr; // Now, remove ' larger'. cout << "Remove ' larger'.\n"; itr = find(strA.begin(), strA.end(), 'l'); strA.erase(itr, itr+7); cout << strA << "\n\n"; return 0; }