fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <iterator>
  5. #include <algorithm>
  6.  
  7.  
  8. int main() {
  9. std::vector<std::string> text;
  10. for (std::string line; std::getline(std::cin, line); text.push_back(line));
  11.  
  12. std::cout << "Before:" << std::endl;
  13. std::copy(text.begin(), text.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
  14.  
  15. for (std::vector<std::string>::iterator it = text.begin(); it != text.end(); ++it) {
  16. std::replace_if(it->begin(), it->end(), ispunct, ' ');
  17. }
  18.  
  19. std::cout << "After:" << std::endl;
  20. std::copy(text.begin(), text.end(), std::ostream_iterator<std::string>(std::cout, "\n"));
  21. }
  22.  
Success #stdin #stdout 0s 2992KB
stdin
Balh fd gf, ,,dffdg,g, f,gf
dfs;,ml;sf,,!/?gdfgfd,??/.
.,.,dfs<.?/ >>//???><>.,.,.
stdout
Before:
Balh fd gf, ,,dffdg,g, f,gf
dfs;,ml;sf,,!/?gdfgfd,??/.
.,.,dfs<.?/ >>//???><>.,.,.
After:
Balh fd gf    dffdg g  f gf
dfs  ml sf     gdfgfd     
    dfs