C++ help needed

Spydermag68

Platinum Member
Apr 5, 2002
2,616
99
91
I need some help so that after I enter a string that the <return> is caught and the loop ends.
 

Spydermag68

Platinum Member
Apr 5, 2002
2,616
99
91
The cin >> s1 stops at each space creating a string the length of one word.

The loop is there so I can read in each word and do some processing on each word.

I need it to stop at the end of the line. Right now after I hit enter on the input it processes the line and waits for more input. I want it to break out of the loop and end the program.



 

itachi

Senior member
Aug 17, 2004
390
0
0
use 'getline' instead.. the stream extraction operator reads until it reads a space or newline. getline uses newline as it's delimiter.

string str;
getline(cin, str);