|
|
cin >> question;
only reads one word and leaves the rest in the input stream.cin >> inNum;
, it tries to read in the rest of what you typed in for the first question and chokes up because that's not an int
.getline(cin, question);
cin >> something
, because cin >> something
will leave the newline character (from you pressing Enter) in the input stream, but getline stops immediately after it sees a newline character.cin.ignore();
after doing cin >> something;
but before doing getline(cin, somethingelse);
.
|
|
cin >> x;
, and when it loops back around, the call to getline eats the leftover newline character instead of waiting for an input.