I was working on my search function when I came across this problem. It's driving me mad...
Code: Select all
while( !quit )
{
cout << "Enter a string to be searched for: ";
getline( cin , str );
searchString( strList , str );
if( !again() )
{
quit = true;
}
}
if I add a line after getline()
cin.get( discard );
Where discard is a char variable, I can get rid of the '\n' that getline doesn't pick up. It works, but it makes the program pause after the getline() until there's a keypress. I also don't want this. Similarly, I can use cin.ignore( 1000 , '\n' ) but this will also make the program stop and wait for a return press.
I'm at a loss of wtf I should do to instruct the program to take the string, then continue without undesired behavior.