I am having trouble with finding and erasing part of a string. For example, the string "pork and beans". We had to find the first occurrence of "and" and place "not" after the "and" to make it "pork and not beans"
Then we are supposed to erase the "not".
all remove() to remove " not" from the string str. The function remove() will receive str as a reference parameter. After changing str, remove() will print the changed string.
So far I've come up with this:
The second parameter in the erase function is way off, I know. I was just trying anything. I'd appreciate anyones helpnCode:void remove (string &str) { string::size_type pos; pos = str.find ("not", 0); str.erase (pos, str.length()); cout << str << endl << endl; }