I'm writing a menu driven program with a switch statement and while loop. My prof wants us to include "Press any key to continue..." and says to use getchar() for this. He says we will lose points if it requires us to press enter, which is what happens for me when I use the getchar().
I have seen many posts about using getch() with , however this is not working because I am using a C program compiled and executed with cygwin.
Thanks in advance
EDIT Updating since I have not seen any answer for this specific question using Unix/Linux... Emailed my prof and he got back to me with this...
"Unix/Linux issues. The keyboard input/output is buffered, i.e., your program might not get the character immediately after a user presses a key. Usually, the Operating System (OS) will send characters pressed after an ENTER key is pressed. If you want your program to get the character immediately after the user pressed it, run the following command in your shell (command window or Terminal). You only need to run it once after you first open your shell stty -icanon min 1
I did this command in the shell before compiling and it still didn't work.
I then used getchar(); twice in a row since a scanf was used previously and doesn't consume the enter used and passes it to the first getchar();
Now it works and I can press ANY key to continue...