Read from cin if there is something within some time, otherwise skip

Hello!

I need a program to make that if something (for example, a char) is entered from cin within a certain amount of time, it reads it, but if nothing is entered, it doesn't wait and continues with the program.

Thanks!
I think this would require multi-threading.

1. Create a new thread.
2. Start a timer using your OS API (or maybe boost) in the original thread
3. Use the std::cin object in the new thread.
4. When the timer expires in the original thread, delete the new thread.
+1 Stewbond, I just want to add that SFML has a pretty easy to use cross-platform threading library as well.
Topic archived. No new replies allowed.