Take a look at remove_if()
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
string s;
getline(std::cin,s);
cout << s << endl;
s.erase (std::remove_if(s.begin (), s.end (), ispunct), s.end ());
cout << s << endl;
}
4
solved Removing punctuation from string of characters [closed]