fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4. int main()
  5. {
  6. std::string s = "abc\n12d\nf34";
  7. std::replace_if(s.begin(), s.end(), [](char c) { return (c == '\n' || c == '\r'); }, ' ');
  8. std::cout << s << std::endl;
  9. return 0;
  10. }
Success #stdin #stdout 0.01s 5272KB
stdin
Standard input is empty
stdout
abc 12d f34