I was wondering if there was a way to ignore getch() after an amount of time has passed.
Like, if i wanted the user to press a key within 5 seconds of me telling them to, or else the program closes, or something like that. How would I do that, or is there something other than getch() that has to bee used?
One f the more easier alternatives for beginners would be to use _kbhit() from the (severely depricated) conio.h header file. it will return true if a key was pressed (or if there is a character key code in the buffer), and false otherwise.
If you are up to it, I would suggest following LB's approach.
1 2 3 4 5 6 7 8 9 10
while(time != time_up)
//update the time here... etc...
ch = getch();
//user pressed nothing, return nothing, or somthing