I would like to remove apostrophe present in a string. I tried to write something but it seems that my syntax is wrong. I can’t figure out where the problem is, but I know that something is not right in my syntax. I use Dev-C++.
{...
cout<<"enter the word to test "<<endl;
getline(cin,givenword);
string str (givenword);
std::string deleteapostr(givenword);
// trying to delete apostrophe if present in the string
deleteapostr.erase(std::remove_if(deleteapostr.begin(), deleteapostr.end(), '\'', deleteapostr.end());
...
}
remove_ifrequires a predicate for its 3rd argument, not an element value. You want plain oldremove.You’re missing a closing parenthesis for the arguments to
remove_if.