#include #include using namespace std; string remove(string s1, string s2) // post: removes first occurrence of s2 from s1 and returns the resulting string. // Returns s1 if s2 does not occur any. { unsigned int location; location = s1.find(s2); if (location != string::npos) { return s1.substr(0, location) + s1.substr(location+s2.length(), s1.length()); } return s1; } int main() { string s = "Today is Monday", stringtoremove; cout << "string is " << s << endl; cout << "enter the substring to remove: "; cin >> stringtoremove; cout << remove(s, stringtoremove) << endl; return 0; }