|
|
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n')
after line 4 to ignore all input up to and including the newline so when you reach std::getline() this problem does not occur.
it is implementation-defined whether this function does anything with library-supplied streams. ... sync() may empty the get area, or it may refill it, or it may do nothing. ... Visual Studio, where this operation discards the unprocessed input when called with a standard input stream. |