Hello,
I know I can use the functions sleep() or wait() for stopping execution for a given amount of time or until the user presses any key.
But what I want to do is different: I'd like to stop the execution until the user inputs an integer value (which I could simply do with cin), but if the user fails to do so (for example, he's not at the computer) for more than n seconds, the execution should continue assuming a default integer value.
Does anybody know an easy way to have this working?
Thanks a lot,
cheers
Francesco
I'm trying to keep a cross-platform program and I had already worked this out under windows using kbhit, now I'm going to try also the linux solution you posted...
so, thanks a lot!
Francesco
JSYK, kbhit() is not cross-platform even on Windows...
Doing this kind of thing is always platform-dependent. The best that can happen is that you find a library that encapsulates these dependencies for you... Like NCurses.
ah ok, thanks for the info, I thought I could use kbhit on windows and another similar function on linux with some #ifdef to switch. I'll look into NCurses, Francesco