can we force a c++ program to end after a certain amount of time
i want to force my program to quit after a certain amount of time so that it would not go on for ever.....
can we force a c++ program to end after a certain amount of time
i want to force my program to quit after a certain amount of time so that it would not go on for ever.....
It certainly is possible to time your execution.
Like...
SAVE START TIME
PERFORM WORK
CHECK CURRENT TIME
SEE IF CURRENT TIME - START TIME EXCEEDS TOTAL TIME
IF YES EXIT
IF NO REPEAT FROM PERFORM WORK
In fact, it might even be possible with just C++ or C libraries.
This is a similar question to the one about how to restrict memory usage.
If you specify what OS you are using, you can probably get a better answer.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Closed - until the OP learns to provide decent information - see at least two other threads for examples of lack of detail.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.