fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::cout << "Enter any string at all, even if it includes spaces or is very long: " << std::flush;
  7. std::string text;
  8. if(std::getline(std::cin, text))
  9. {
  10. std::cout << "Thanks! You said \"" << text << "\"." << std::endl;
  11. }
  12. else
  13. {
  14. std::cout << "Something went wrong, I didn't quite catch that." << std::endl;
  15. }
  16. }
  17.  
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
Enter any string at all, even if it includes spaces or is very long: Something went wrong, I didn't quite catch that.