im making a timer program. that when a user dont input something in a specific time. the program will go to another menu

so far in my research. threads would be the solution to this. but in my current status right now as a c++ programmer. i dont think im capable of handling threads yet.

any suggestion to how to solve this problem would be greatly appreciated..


dont want to use third party. im not allowed to use them

11 Years
Discussion Span
Last Post by Salem

you could use some os-specific api calls such as Sleep()(ms-Windows) or sleep() (*nix) in a loop to delay a bit then check for keyboard hit.


whats the function that waits for a keyboard input?

in assembly i know that there is a code to doesnt need to press enter to input. it you can loop it so it can act like a timer. but whats the equivalent code for c++?


I don't know of any C/C++ function that waits for user input for a finite/specified time.
Which means you'll have to use multi-threading for sure.
See this thread if it helps.


the link leads you to an error page.

if i have no choice at all i will use multi threading. or just dump this feature in my program.


Perhaps start by saying what kind of program you're writing (console, GUI) and for which Operating System.

It's really hard to make sensible suggestions without a decent level of background information.


sorry dude. anyway the link was kinda helpful thanks.

threads are still my last option. anyway tomorrow if i dont find one il have to learn threading


depending on the compiler there is a non-standard function in conio.h kbhit() that returns true if there is a key waiting at the keyboard buffer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.