How to terminate a program when the time is up in a quiz program

Hi guys!
I'm a beginner at C++ and I want to make a quiz program that is timed. I want that when the time is up, it immediately clears the screen and display a message and terminate the program. any thoughts on how to do this? Thanks in advance! :)
You basically start two threads. One reads input from user and the other does first sleep_for() and then stops the first thread and cleans up.

It might be easier to do with some GUI-framework (e.g. Qt) that already provides "textboxes", "timers", and "event loop".
Last edited on
How does threads work? I don't understand that much, I researched many times in google and none of it seems to work for me, can you give me an example? Thank you
If you are a beginner id advise that you don't even think about threads right now, that's going into more advanced programming.

You might find you'll give yourself a headache ;-)

Is thread the only way to do this?
Let someone else write the threading for you: http://qt-project.org/doc/qt-5/qtimer.html#singleShot
SFML has a nice thread component to their library as well: http://www.sfml-dev.org/documentation/2.1/classsf_1_1Thread.php

That is if you aren't using x11 yet: http://en.cppreference.com/w/cpp/thread/thread
Topic archived. No new replies allowed.