I'm writing a program, and I need to cause a delay for several seconds.
1 2 3 4 5 6 7 8 9 10 11 12
#include <iostream>
usingnamespace std;
int main(){
int x;
//I want to cause a 5 second delay right here.
cout << "Hello World!" << endl;
cin >> x;
return 0;
Add #include <windows.h> so you can use the Sleep function. Sleep(5000);
Each 1000 will equal 1 second. So the 5000, would be 5 seconds. 500 for 1/2 second, etc.