Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • C++

Idiom #45 Pause execution for 5 seconds

Sleep for 5 seconds in current thread, before proceeding with the next instructions.

The pedestrian walks, then stays still for 5 seconds, then resumes walking
#include <thread>
#include <chrono>
using namespace std::chrono_literals;
std::this_thread::sleep_for(5s);
delay 5.0;

New implementation...
< >
programming-idioms.org