Delay after cout

Hi

I want to make a (fake) loading screen before my program i would like it to look like

L(1sec delay)o(1 sec delay) a (1sec delay) and so on here is my code
1
2
3
4
5
6
7
8
9
10
cout << "L" << endl;
cout << "o" << endl;
cout << "a" << endl;
cout << "d" << endl;
cout << "i" << endl;
cout << "n" << endl;
cout << "g" << endl;
cout << "." << endl;
cout << "." << endl;
cout << "." << endl;
On Unix/Linux, you have various sleep() functions. I believe Windows provides something similar with Sleep().
Anyone know how to use that on windows that could explain it I'm kind of intrigued I've always wondered about actually using time.
To try and make it more portable you could use #include <ctime> to make a timing function, but I would definately be easier just to what PanGalactic said(I think...).
Last edited on
You could do it this way, as PanGalactic said:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <Windows.h> //you need this header to use Sleep()

using namespace std;

int main()
{
	cout << "L" << endl;
	Sleep(1000); //this pauses the program for 1000 milliseconds (1 second)
	cout << "o" << endl;
	Sleep(1000);
	cout << "a" << endl;
	Sleep(1000);
	cout << "d" << endl;
	Sleep(1000);
	cout << "i" << endl;
	Sleep(1000);
	cout << "n" << endl;
	Sleep(1000);
	cout << "g" << endl;
	Sleep(1000);
	cout << "." << endl;
	Sleep(1000);
	cout << "." << endl;
	Sleep(1000);
	cout << "." << endl;
	Sleep(1000);
	return 0;
}
Oh that's awesome I thought there would be something like that I just never found it.
Topic archived. No new replies allowed.