This program reads the first line over and over again. Everywhere I have looked for answers I have learned that it should read the next line after hitting "Enter". Why doesn't it?
#include<iostream>
#include<sstream>
using namespace std;
int main() {
stringstream ss;
string line, str;
while(getline(cin, line) ){
ss.str(line);
ss >> str;
cout << str << endl;
cout << endl;
}
return 0;
}
Output looks like this
Hello
Hello
World!
Hello
and
Hello
again
Hello
Hello
Hello