time based entry

how can i make a program which allows a user to enter an input for a time interval for example i ask a question and sets the input to be entered within 10 seconds...
can some one help me with this?
Without getting into threads the simple answer is to save a time stamp after you post the question to the screen and compare it to the time stamp after the user inputs his answer. If the difference is greater then ten seconds, disqualify the answer.
is it complicated to do it in real time..in a quiz doing the second option what u told is like an awkward...
if the user does not enters the answer in 10 seconds there will be negative marking and the next question would show up...if this could be done...it will be more fun and more challenging..
pls help me..
Sure it can be done. You just need an x11 compliant compiler and the requisite header files. Try using the "std::thread' object: http://www.cplusplus.com/reference/thread/thread/ and the "std::timed_mutex" object: http://www.cplusplus.com/reference/mutex/timed_mutex/
can i use 'join' to do the above mentioned ?
i am not able to exactly figure out how to use them but i think i can make one function for 'cin' and the other for 'clock' and can join them and when clock finishes its execution cin also pauses...something like that..is this right or pls tell me how to use it?
Topic archived. No new replies allowed.