fork(2) download
  1. // remove algorithm example
  2. #include <iostream> // std::cout
  3. #include <algorithm> // std::remove
  4. using namespace std;
  5. void replaceCharsInString( string &str, const string &c ){
  6. for (unsigned int i = 0; i < c.length(); ++i){
  7. str.erase (remove(str.begin(), str.end(), c.at(i) ), str.end());
  8. }
  9. }
  10. int main () {
  11.  
  12. //STRINGYNIZE!
  13. string str = "a|b/c?d:e?";
  14. replaceCharsInString( str, "|/?:" );
  15. cout << "new string contains:" << endl << str;
  16.  
  17. return 0;
  18. }
Success #stdin #stdout 0s 3276KB
stdin
Standard input is empty
stdout
new string contains:
abcde