-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
41 lines (30 loc) · 843 Bytes
/
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
#include <stdexcept>
#include <iostream>
#include <fstream>
#include <string>
#include "Machine.hpp"
using namespace std;
int main(int argc, char **argv) {
if (argc > 1) {
argc--;
argv++;
Machine machine(argc, argv); //stack
string input;
char c;
while (cin >> c) {
if (isupper(c)) {
input.push_back(c);
} else if (isspace(c) || c == '\t' || c == '\r' || c == '\n') {
continue;
} else if (c == EOF) {
break;
} else {
throw invalid_argument("Invalid input for Enigma encryption.");
}
}
string output = machine.encrypt(input);
cout << output << endl;
} else {
throw invalid_argument("Invalid program arguments.");
}
}