-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathloadbar.cpp
More file actions
75 lines (66 loc) · 1.11 KB
/
Copy pathloadbar.cpp
File metadata and controls
75 lines (66 loc) · 1.11 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>
#include <cstring>
#include <cmath>
#include <unistd.h>
using namespace std;
string input = "";
char loadBar[50];
int barSize = 15;
float percent = 100/barSize;
void setProgress(int prog)
{
float mult = prog * 0.01;
int index = floor(barSize * mult);
memset(loadBar,'-',barSize);
memset(loadBar,'#',index);
cout << "[" << loadBar << "]" << prog << "%\r";
cout.flush();
}
int function()
{
sleep(0.5);
setProgress(14);
sleep(1);
setProgress(41);
sleep(5);
setProgress(76);
sleep(1);
setProgress(100);
cout << endl;
return 5;
}
void loadFunc()
{
for(int j = 0; j < barSize; j++)
{
loadBar[j] = '-';
}
cout << "Loading..." << endl;
for(int i = 0; i <= barSize; i++)
{
memset(loadBar, '#', i);
cout << "[" << loadBar << "]" << i*(int)percent << "%\r";
cout.flush();
sleep(1);
}
}
int main()
{
cout << ">";
cin >> input;
while(input != "q")
{
if(input == "function")
{
cout << function();
}
else if(input == "load")
{
loadFunc();
}
cout << endl;
cout << ">";
cin >> input;
}
return 0;
}