In JavaScript, there is a function called setInterval(). Can it be achieved in C++? If a loop is used, the program does not continue but keeps calling the function.
setInterval()
Use std::thread to achieve.
std::thread
// should have been included void setInterval(auto function,int interval) { thread th([&]() { while(true) { Sleep(interval); function(); } }); th.detach(); } //... setInterval([]() { cout<<"1 sec past\n"; }, 1000);