If you have a cin >> something;
call prior to your system()
call.
For example, taking input into an integer. When cin >> myintvar;
(or similar) then the integer is placed in myintvar
and the '\n' gets sent along in the stream. The getline
picks the \n
up as indicative of the end of a line of input, so it is effectively "skipped".
Either change the cin >>
to a getline()
or call cin.ignore()
to grab the '\n'
(or better, call a cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n' );
to flush the input buffer-- but be sure you're not throwing away valuable input in the process).