1using namespace std;
2
3string BasicString = "I dont like erasing strings";
4string StrToErase = " dont";
5
6string::size_type i = BasicString.find(StrToErase);
7
8if (i != string::npos)
9{
10 BasicString.erase(i, StrToErase.length());
11}
12
13cout << BasicString << "\n"; // OUTPUT: I like erasing strings
14
1 string& erase (size_t pos = 0, size_t len = npos);
2/*
3pos
4Position of the first character to be erased.
5If this is greater than the string length, it throws out_of_range.
6Note: The first character in str is denoted by a value of 0 (not 1).
7len
8Number of characters to erase (if the string is shorter, as many characters as possible are erased).
9A value of string::npos indicates all characters until the end of the string.
10*/