Horje
How to pause a c++ program. Code Example
c++ pause
#include <Windows.h>

int main() {
	//do stuff
	system("Pause");
}
How to pause a c++ program.
//On windows.
#include<windows.h>
Sleep(milliseconds);

//On linux.
#include<unistd.h>
unsigned int microsecond = 1000000;
usleep(3 * microsecond);//sleeps for 3 second

// c++ 11 for high resulution.

#include <chrono>
#include <thread>

int main() {
    using namespace std::this_thread; // sleep_for, sleep_until
    using namespace std::chrono; // nanoseconds, system_clock, seconds

    sleep_for(nanoseconds(10));
    // or 
    sleep_until(system_clock::now() + seconds(1));
}

// C++ 14 for high resuluton.

#include <chrono>
#include <thread>

int main() {
    using namespace std::this_thread;     // sleep_for, sleep_until
    using namespace std::chrono_literals; // ns, us, ms, s, h, etc.
    using std::chrono::system_clock;

    sleep_for(10ns);
  	// or
    sleep_until(system_clock::now() + 1s);
}




Cpp

Related
min element in stl c++ Code Example min element in stl c++ Code Example
how to get an element in a list c++ Code Example how to get an element in a list c++ Code Example
how to find size of int array in c++ Code Example how to find size of int array in c++ Code Example
c++ random number generator uniform distribution Code Example c++ random number generator uniform distribution Code Example
c++ remove text file Code Example c++ remove text file Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9