how to make a limited time for an input function?

Hi guys!
I need a way to make a limited time for the cin such that the user should have a limited time to enter something. if the user entered something in the time it will be assigned to a variable. but if the time ended before entering anything, the program should then complete doing something else leaving the cin.
so how shall I do that? like can the program run two functions in the same time? like cin and Sleep() in the same time and when the Sleep() finishes, is there an order to cancel the cin or something?
Last edited on
cin has no facility for timed input.

To do this you're going to have to use OS specific input facilities that support this. Since you didn't state what OS you're using, can't point you to specific routines.

I am a beginner and I only know the cin and the scanf() so what kind of input function should I learn to do that?
I repeat my question to you.

What operating system?
Oh, I didn't got it?!
I barely know somethings in C++. I am just making a simple program that works on the console app. what do you mean by OS? like windows, android? or something like that? no. I am so far from that level. I barely write simple console applications.
Last edited on
My friend, He is just simply asking if you program on Windows, or Linux, Or Mac, or whatever, becuase they each have their own specific ways of answering your questions. So please just give the man a straight answer so he can help you.
Topic archived. No new replies allowed.