C++: sleep in MinGW 

Joined:
04/09/2007
Posts:
775

January 31, 2009 16:50:57    Last update: January 31, 2009 16:50:57
MinGW uses native windows API and there's no unix compatible sleep function. Windows native Sleep (with capital S) sleeps in milliseconds.
#include <iostream>
#include <windows.h>
#define sleep(n) Sleep(1000 * n)
using namespace std;
int main() {
    cout << "Sleeping for 1 sec..." << flush;
    sleep(1);
    cout << "done" << endl;
}
Share |
| Comment  | Tags
1 comment