I know this question has been asked before, but nothing helped.
I have a program
void printInstructions(){
cout << "\n******INSTRUCTIONS******\n"
// a lot of text
<< "Press any key to begin...\t";
/*cin.sync();
*cin.get()
*cin.ignore(1);
*cout << flush;
*/
string temp;
cin >> temp;
cout << '\n';
}
int main()
{
cout << "***********************\n"
<< "******* WELCOME *******\n"
<< "***********************\n"
<< endl;
//some stuff
printInstructions();
//some other stuff
}
I commented all the solutions i tried and only the one with the temp
works, but with that being clumsy I'm interested why the cin.get()
or cin.ignore()
don't work. And yes, I tried std::flush, but it just skipped the cin.
call and went onward with the program