I assume this is the console, yes?
My first instinct is to say "Don't do this. The console is not designed for this kind of thing."
That said... the big problem with standard IO is that it's blocking. This means when you use cin to get some input from the user... your code is blocked (it does not execute) until the user inputs something.
For you to accomplish what you want, you will need to use a non-blocking input method. The standard library
does not provide any non-blocking input methods, so you'll have to use other libs.
The most available is probably kbhit() and getch() from <conio.h>. While not part of the standard lib, it is widely available so you probably have it on your machine.
I never use it myself... but I found this example from google:
http://stackoverflow.com/questions/15603082/how-to-use-kbhit-and-getch-c-programming
The thing to note here is that kbhit is
non-blocking which means if the user did not input anything, kbhit will not wait around like cin will. It will return immediately.
This will allow you to run other code (like having a timer count up to 10 seconds) while you wait for the user to input something.
EDIT:
2x ninjas
dhayden's approach is much simpler than mine and will probably work great for your purposes. The key difference between his approach and mine is that his approach will still wait around forever for the user to input something... but will reject it if they did not provide it in time. Whereas my approach would give you the ability to actually interrupt and stop waiting around once time has expired.
I
do not recommend threads for this. Having another thread doesn't help much when your input is blocking... because the only way to unblock it would be to forcibly kill the thread... which is not advised.