fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4.  
  5. int main() {
  6. std::string text;
  7.  
  8. std::cout << "Enter inserting text: ";
  9. std::getline(std::cin >> std::ws, text);
  10.  
  11. std::string::size_type pos = text.find("\\n");
  12. while (pos != std::string::npos)
  13. {
  14. text.replace(pos, 2, "\n");
  15. pos = text.find("\\n", pos+1);
  16. }
  17.  
  18. std::cout << text;
  19. return 0;
  20. }
Success #stdin #stdout 0s 2876KB
stdin
  hello \n Bye
stdout
Enter inserting text: hello 
 Bye