#include#include #include #include #include #include using namespace std; using namespace std::chrono; int main() { steady_clock::time_point start = steady_clock::now(); while (true) { auto current = steady_clock::now(); if (duration_cast (current - start).count() == 5) { cout << "Timer Complete" << endl; start = current; } // do other stuffs } return 0; }
#includeC++ Timer is part of the Boost Library, which is a set of libraries for the C++ programming language that provide support for tasks such as type checking, multithreading, networking, and file system access.#include #include using namespace std; using namespace std::chrono; int main() { int countdown_sec = 10; for(int i = countdown_sec; i >= 0; i--) { cout << i << endl; std::this_thread::sleep_for(std::chrono::seconds(1)); } cout << "Timer Complete" << endl; return 0; }