fork(4) download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4.  
  5. void RemoveCharacterFromString(char character_for_remove, std::string &string) {
  6. auto it = std::remove_if(std::begin(string), std::end(string),
  7. [=](char c) { return c == character_for_remove; });
  8. string.erase(it, std::end(string));
  9. }
  10.  
  11. int main() {
  12. std::string string = "aaa bbb ccc ddd ccc fff";
  13. RemoveCharacterFromString('c', string);
  14. std::cout << "after remove: " << string << '\n';
  15. }
  16.  
Success #stdin #stdout 0s 3228KB
stdin
Standard input is empty
stdout
after remove: aaa bbb  ddd  fff