#include <string>
#include <algorithm>
#include <iostream>
using namespace std;
int main ()
{
string strSample ("Hello String!");
// Find a character 'S' in the string using STL find algorithm
string::iterator iCharS = find ( strSample.begin (), strSample.end (), 'S');
// If character found, 'erase' to deletes a character
cout << "Erasing character 'S' from the sample string:" << endl;
if (iCharS != strSample.end ())
strSample.erase (iCharS);
cout << strSample;
return 0;
}
|