Example 1: cpp thread sleep
#include <iostream> #include <thread> #include <chrono> int main() { std::cout << "countdown:\n"; for (int i=10; i>0; --i) { std::cout << i << std::endl; std::this_thread::sleep_for (std::chrono::seconds(1)); } std::cout << "Lift off!\n"; return 0; }
Example 2: c++ sleep function
#include <chrono> #include <thread> std::this_thread::sleep_for(std::chrono::milliseconds(x));
Example 3: sleep c++ windows
#include <Windows.h> Sleep(number of milliseconds);
Example 4: sleep in c++ linux
#include <unistd.h> sleep(10);
Example 5: sleep c++
#include <unistd.h> unsigned int sleep(unsigned int seconds);
Comments
Post a Comment