retrieving a single character in VC++
Posted on 2000-03-25
I'm presently using MS Visual C++ 6 and I would like to know the best way to input a single character (with no need for the user to press enter). I've tried using the _getch, which works, but it does not display my prompt until after the _getch function is executed(the program sits there with a blank screen waiting for input).
Then if I ask the user for more input the inputted character is echoed after the prompt.
cout<<"Enter a character: ";
ch = _getch();
cout<<"Enter an integer: ";
(screen is blank at this point waiting for input even though the prompt should be there....so I press a character then the following is displayed)
Enter a character: g
Enter an integer: g
I understand it's a stream related problem, but I have no idea what's going on in the streams.
Thanks in advance,