I basically need a function that, after a certain amount of time has elapsed, will restart a program from scratch. This is because the code can get stuck at a certain point if wrong decisions are made. I am curious how to go about making this. I am sure it should be quite simple. Could I just use some sort of time function for this? For example, when time = 30 seconds since last restart, the program starts over?
zoner7 22 Junior Poster
Recommended Answers
Jump to PostBy stuck I suppose you mean the program goes into an infinite loop or possibly even crashes. You should fix the problem instead of attempting to hide it.
Jump to PostOh, you mean keyboard input. In that case you need to create another thread. The main thread should do the timing and the second thread the keyboard input. When time expires in the main thread, main() kills the keyboard thread then does other things.
All 5 Replies
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Nick Evan commented: Good advice +6
Agni 370 Practically a Master Poster Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Prabakar 77 Posting Whiz
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
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.