The
MSDN says that the
getch()
function is deprecated and suggest to use the
_getch() function[
^] instead. Its documentation states:
The _getch and_getwch functions read a single character from the console without echoing the character. None of these functions can be used to read CTRL+C.
When reading a function key or an arrow key, each function must be called twice; the first call returns 0 or 0xE0, and the second call returns the actual key code.
These functions lock the calling thread and are therefore thread-safe. For non-locking versions, see _getch_nolock, _getwch_nolock.
I think that this should work properly:
printf("Press F1 key to continue.\n");
while (true)
{
int c = _getch();
if (c != 0x00 && c != 0xE0) continue;
if (_getch() == 0x3B) break;
}