In C++11, you can use std::this_thread::sleep_for()
to get your program (well, the current thread, strictly speaking) to pause for approximately the length of time you specify. For example:
#include <chrono>
#include <thread>
using namespace std::chrono_literals;
int main()
{
int variable = 0;
while (variable < 10) {
std::this_thread::sleep_for(1s); // sleep for one second
++variable;
}
}
solved how to check if a second has elapsed c++