how to pause a c 2b 2b program

Solutions on MaxInterview for how to pause a c 2b 2b program by the best coders in the world

showing results for - "how to pause a c 2b 2b program "
Isabelle
03 Jul 2017
1#include <Windows.h>
2
3int main() {
4	//do stuff
5	system("Pause");
6}
Elio
19 Mar 2017
1//On windows.
2#include<windows.h>
3Sleep(milliseconds);
4
5//On linux.
6#include<unistd.h>
7unsigned int microsecond = 1000000;
8usleep(3 * microsecond);//sleeps for 3 second
9
10// c++ 11 for high resulution.
11
12#include <chrono>
13#include <thread>
14
15int main() {
16    using namespace std::this_thread; // sleep_for, sleep_until
17    using namespace std::chrono; // nanoseconds, system_clock, seconds
18
19    sleep_for(nanoseconds(10));
20    // or 
21    sleep_until(system_clock::now() + seconds(1));
22}
23
24// C++ 14 for high resuluton.
25
26#include <chrono>
27#include <thread>
28
29int main() {
30    using namespace std::this_thread;     // sleep_for, sleep_until
31    using namespace std::chrono_literals; // ns, us, ms, s, h, etc.
32    using std::chrono::system_clock;
33
34    sleep_for(10ns);
35  	// or
36    sleep_until(system_clock::now() + 1s);
37}