Pause program execution for 5 seconds in c++
c++
Solution
#include <iostream>
#include <chrono>
#include <thread>
int main()
{
std::cout << "Hello waiter" << std::endl;
std::chrono::seconds dura( 5);
std::this_thread::sleep_for( dura );
std::cout << "Waited 5s\n";
}
`this_thread::sleep_for` Blocks the execution of the current thread for at least the specified sleep_duration.
Problem
I want to pause the execution of c++ program for 5 seconds. In android Handler.postDelayed has the required functionality what I am looking for. Is there anything similar to that in c++?