I am trying to find a way to pause or sleep my simple c++ program such as the time.sleep(x)
in Python. Is there an equivalent in C++? An example of where I would want to use this is in here:
#include <iostream>
using namespace std;
int main() {
for (int x = 0 ; x < 100 ; x++) {
cout << 100 - x << " bottles of beer on the wall, "
<< 100 - x << " bottles of beer!\nTake one down pass it around "
<< 100 - (x + 1) << " bottles of beer on the wall\n\n";
//enter sleep here to pause before next output
}
}
Thanks
You can use
Sleep(ms)
function from WinAPI or POSIXusleep(mcrsec)