Hi I'm coding a program to run under the console (UNIX) and need a way to hold the screen until the user hit's the <RETURN> key before proceeding. I have usually achieved this in other languages by just having a temp read in statement and it works fine but under C++ it behave differently.
This is the function I made:
But this requires the user to type a char, but all I want is the user to hit return without typing anything. Also the problem with this is that is the user enters more than 1 char then a bug occurs.Code:void waitForReturnKey() { char temp; cout << "Press <RETURN> to continue..." << endl; cin >> temp; }




Reply With Quote