0
isspace() is breaking input?
I'm writing a code to help speed up an in-game inventory system, and I need to use isspace to make sure it doesn't get counted as a consonant. However, it causes anything past the space to not be counted, and seemingly breaks the cin command. https://code.sololearn.com/cR0Pobm79v1B/#
1 ответ
+ 2
It's not isspace(). It's how cin will works. cin will only grab chars up to the first whitespace character.
string s;
char c;
cin >> s;
If "how are you?" is entered s will only be equal to "how" and the rest of the input is left in the input stream.
You need to use getline() to get all the chars up to a \r\n etc.
Note; there are 2 versions of getline().
Review them both to see which you need.
http://www.cplusplus.com/reference/string/string/getline/
http://www.cplusplus.com/reference/istream/istream/getline/