fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. using namespace std;
  7.  
  8. string line;
  9. while (getline(cin >> ws, line))
  10. cout << "got: " << line << endl;
  11. return 0;
  12. }
  13.  
Success #stdin #stdout 0.01s 5384KB
stdin
line 1 followed by an empty line (no spaces)

line 2 followed by a line filled with 3 spaces
   
   line 3 - the last one, prefixed with 3 spaces
stdout
got: line 1 followed by an empty line (no spaces)
got: line 2 followed by a line filled with 3 spaces
got: line 3 - the last one, prefixed with 3 spaces