STR. Erase (STD: : remove (STR) the begin (), STR. The end (), 'a'), and STR. The end ());
So if there are two objects in the string, if you want to delete all objects in the object 1 2 contains characters, or string in the algorithm have a ready-made functions support?
And don't like here so the definition of double circulation to remove trouble?
Strings str1 str2;
Getline (cin, str1);
Getline (cin, str2);
String: : iterator ite1;
String: : iterator ite2;
For (ite1=str1. The begin (); Ite1!=str1. End (); Ite1 + +)
{
For (ite2=str2. The begin (); Ite2!=str2. End (); Ite2 + +)
{
If (* ite1==* ite2)
Str1. Erase (ite1);
}
}
For_each (str1. The begin (), str1. The end (), fun);
CodePudding user response:
StringReplace (STR, "to delete the string", "", TReplaceFlags () & lt;