Possible Duplicate:
C/C++: Capture characters from standard input without waiting for enter to be pressed
char ch;
think I want to get a character. I know two different ways.
1- using cin command in iostream header file.
cin >> ch;
It will wait for user to type something, then user MUST press enter to send input into ch variable.
2- getch() command in conio.h header file.
ch = _getch();
It will wait for user to type something, as soon as typing a character it will be saved in ch variable and user DOES NOT need to press enter. BTW this code will stop program and will wait for an input.
Now I want to write a command which does not need pressing enter and it does not stop program for pressing something. Just imagine I delay program for 1 seconds, if user presses something it will save it into ch variable, if not nothing, program will continue and it won't stop for pressing something. It is like a picker command, if there is something it will pick it up, if not it will continue.
Hope I'm clear. So how to do it?