ive been writing a c++ program to make a quiz but i couldn't figure out about how u can put a timer.
the timer should actually countdown from 20 to 1 and once the time is over it has 2 move on to the next question and no points should b given 4 that question.

can someone write out a code and explain the logic to me.

p.s in the code please include a question

you have to put the timer code in a second thread then when someone types something in thread1 kill the timer thread. How to construct new threads depends on the operating system.

this maybe what your looking for

http://www.cplusplus.com/reference/clibrary/ctime/clock.html

Not for this purpose because you can't get keyboard input while that wait function is working.

There is a way to do it with non-standard c functions from conio.h, but they are generally discouraged because most compilers don't implement them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.