a non blocking getch() ????
I have a loop whose running time is really longe and I want to save my variables before the loop finishes if requested by the user, but I don't want to block (wait for user to answer), like I need a method to check after an iteration finishes if the user have enterd a spesific key (say 's') if yes then save if not then continue to the other iteration.
now this can't be done by _getch() of cin since both will wait for the user to input something (i.e. is the user didn't press anything the execution will halt on them) :( so is there a function or a trick to just see if the user entered anything without halting for an input?
if the idea is not clear tell me to clarify further
any help will be appriciated
Re: a non blocking getch() ????
Is this a console app? Maybe the old _kbhit() DOS function is still available and you can check for a keyboard hit in your loop before calling getch().
If it's a Windows app you should implement keyboard message handlers in your window.
Re: a non blocking getch() ????
its a console application, and how exactly do I check for a keyboard hit? (without waiting)
Re: a non blocking getch() ????
yes thanks _kbhit() works :D