-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
49 lines (43 loc) · 1.06 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
/**
HQ9+ 🍋
Lucas Larson
copyright GPL v3.0+
https://github.com/LucasLarson/HQ9
*/
#include <climits>
#include <cstring>
#include <iostream>
#include <string>
#include "beer.hpp"
#include "helloWorld.hpp"
#define BUFFER_SIZE INT_MAX / UCHAR_MAX - USHRT_MAX
int main() {
char input[BUFFER_SIZE];
std::cin.width(BUFFER_SIZE);
u_int64_t plus = 0;
std::cout << std::string(25, '\n');
std::cout << "This is HQ9+" << std::endl;
std::cout << "interpreted by C++20" << std::endl;
std::cout << " a Lucas Larson production" << std::string(3, '\n');
for (;;) {
std::cout << "↪ ";
std::cin >> input;
input[BUFFER_SIZE - 1] = '\0';
for (u_int64_t index = 0; index < strnlen(input, BUFFER_SIZE); index++) {
if (input[index] == 'H') {
helloWorld();
} else if (input[index] == 'Q') {
printf("%s\n", input);
} else if (input[index] == '9') {
beer();
} else if (input[index] == '+') {
plus++;
#if DEBUG
printf("%llu\n", plus);
#endif
} else {
return 1;
}
}
}
}