-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.cpp
53 lines (50 loc) · 1.17 KB
/
main.cpp
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
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string_view>
#include <vector>
int main() {
std::string name;
bool premium = false;
std::string s;
std::string_view command = "ls";
std::cout << "What's your name? ";
std::cin >> name;
int choice;
while (1) {
std::cout << "==== Menu ====" << std::endl;
std::cout << "1. Change name" << std::endl;
std::cout << "2. Status" << std::endl;
std::cout << "3. Set command" << std::endl;
std::cout << "4. Execute command" << std::endl;
std::cout << "> ";
std::cin >> choice;
switch (choice) {
case 1:
std::cout << "What's your new name? ";
std::cin >> name;
break;
case 2:
std::cout << "==== Status ====" << std::endl;
std::cout << "Username: "
<< "@" + name << std::endl;
std::cout << "Is premium: " << premium << std::endl;
break;
case 3:
std::cin >> s;
if (!premium) {
command = "#" + s;
}
break;
case 4:
std::cout << "Executing " << command << std::endl;
std::system(command.data());
break;
default:
std::cout << "Invalid choice" << std::endl;
exit(0);
}
}
return 0;
}
// g++ main.cpp -Wall -g -o chall