How to time out user input

Hi,

I am using scanf to get user input, but I need to have a time out, so that in case user doesn't respond in 30 seconds, I will time out and return to a known state. Does anyone know how to do this and maybe have an example? I read but scanf doesn't seem to timeout.

Thanks,
Monkey
In DOS programming, in <conio.h> there is a kbhit() function that checks if there is anything in input buffer. Using it you may determine whether user started typing.
You may get input by separate characters and track the situation when the user would not press 'Enter' in 30 seconds.
I belive you won't be able to track the time expiration if using 'stopping' functions like scanf(), getchar(), etc., which wait for 'Enter' to be pressed.
Topic archived. No new replies allowed.