Ok, this has been throwing me off in my programs for a while now. I don't understand why sometimes it works just fine and sometimes it creates a need for a keyboard entry to continue. Here is some example code where I am having the issue with cin.ignore() needing a return after the getline() function.
bool validfile = false;
if (retrycnt == 0)
cout << "Sorry, your file is in another castle...\n\n";
cout << "Hello! What file are we checking? ";
if (!infile && retrycnt > 1)
cout << "File not found! " << retrycnt - 1 << " attempts remaining... \n\n";
elseif (!infile && retrycnt == 1)
validfile = true;
I have written this loop a thousand times! Ok, maybe not a thousand... but sometimes it works like a charm and other times like this, it's acting like there are still some characters or a character stuck in the buffer. This is so confusing! Help?