|
-
December 9th, 2008, 07:58 PM
#1
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
-
December 10th, 2008, 07:47 AM
#2
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.
-
December 10th, 2008, 02:01 PM
#3
Re: a non blocking getch() ????
its a console application, and how exactly do I check for a keyboard hit? (without waiting)
-
December 10th, 2008, 02:10 PM
#4
Re: a non blocking getch() ????
yes thanks _kbhit() works
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|