-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
85 lines (77 loc) · 2.18 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
Hello World
Copyright (C) 2022 butztill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <iostream>
#include <fstream>
#include <regex>
using namespace std;
int runningon()
{
ifstream lsbrelease;
lsbrelease.open("/etc/lsb-release");
string lsbout;
string parsed;
if (lsbrelease.is_open()){
lsbrelease >> lsbout;
regex regex1("DISTRIB_ID=\"(.*)\"");
smatch matches;
regex_search(lsbout, matches, regex1);
parsed = matches.str(1);
cout << "You use " << parsed << " btw.\n";
lsbrelease.close();
} else {
cout << "error: file could not be opened.\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
int helloworld()
{
cout << "I will add 1 to your input."
<< endl
<< "Please input a number:"
<< endl;
int a;
cin >> a;
a = a+1;
cout << "The result is " << a << ".\n";
if (a > 10) {
cout << "What you entered is greater than 10.";
} else {
cout << "What you entered is not greater than 10.";
}
return EXIT_SUCCESS;
}
int main(void)
{
int choice;
do{
cout << "1. runningon\n"
<< "2. helloworld\n"
<< "3. exit\n";
cin >> choice;
switch(choice) {
case 1:
runningon();
break;
case 2:
helloworld();
case 3:
cout << "\nexiting.\n";
default:
return 0;
}
} while(choice !=3);
return EXIT_SUCCESS;
}