fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void remove(std::string& str, char ch)
  5. {
  6. int pos = str.find_first_of(ch);
  7. while (pos != std::string::npos)
  8. {
  9. str.erase(str.begin()+pos);
  10. //cout << pos << " " << str << endl;
  11. pos = str.find_first_of(ch);
  12. }
  13. }
  14. int main() {
  15. std::string str="PG1} {PG2";
  16. remove(str, '{');
  17. cout << str << endl;
  18. remove(str, '}');
  19. cout << str << endl;
  20.  
  21. // your code goes here
  22. return 0;
  23. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
PG1} PG2
PG1 PG2