Published
- 1 min read
c++ run a loop for a certain time
The solution for this is noted below
c++ run a loop for a certain time
Solution
#include <ctime>
//ctime library to use clock() function
int intial_time =clock();
//initialization of the time as clock() returns the time of the program until its line in miliseconds
while(clock()<intial_time+(//the time u want in miliseconds)){
//the loop u want until the time u want ends
}
//as total the program will just keep checking if he has finished the time u want or not
Try other methods by searching on the site. That is if this doesn’t work