I'm trying to write a console program to exactly duplicate a much older dos-based program.
This older program uses getch() to prompt a user for a response to a question. This program is also used in batch files where a file containing just the response would be redirected into the program so it wouldn't wait for user input.
For example: program.exe < input.txt
It seems as though redirected files don't act the same as user input in a console program even though I expected them both to go through stdin. Getch() doesn't work with redirected files in a console program like in the above example.
I've had success using cin and also with CreateFile with CONIN$ as the input name, to handle keypresses as well as redirected files. However, when handling user keypresses, both alternatives require a carriage return before the input is processed, whereas the original program using getch() only required the keypress - no carriage return necessary.
Is there any Win32 equivalent to the getch() command or some workaround that would work with user keypresses as well as redirected input?
Thanks.
Taz