fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string to_replace = "Hello!!";
  7.  
  8. std::string punctuation = "!.,;:"; // Add more if needed
  9. size_t n = 0;
  10. while((n = to_replace.find_first_of(punctuation, n)) != std::string::npos)
  11. to_replace.erase(n, 1);
  12. std::cout << to_replace;
  13. }
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
Hello