c++ remove substring from string code example
Example: c++ erase substring
using namespace std;
string BasicString = "I dont like erasing strings";
string StrToErase = " dont";
string::size_type i = BasicString.find(StrToErase);
if (i != string::npos)
{
BasicString.erase(i, StrToErase.length());
}
cout << BasicString << "\n"; // OUTPUT: I like erasing strings