-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver.cpp
68 lines (58 loc) · 1.77 KB
/
driver.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
#include "./components/editor.hpp"
#include "./components/testers.cpp"
#include <iostream>
using namespace std;
int main(int argc, char **argv) {
string buf;
if (argc < 2) {
while (1) {
cout << "READ/ENCRYPT or WRITE to file in.txt?" << endl;
getline(cin, buf);
if (buf == "read" || buf == "encrypt") {
tester *help = new tester();
help->encryptalgo();
delete help;
help = nullptr;
return 0x0;
}
else if (buf == "write") {
// use testers.cpp
std::string choice;
std::string input;
int line;
bool f;
int curtime = time(NULL);
std::string filename = "./txt/in.txt";
send output(filename);
// file is now open for all read/write operations
std::cout
<< "Begin typing below. Type ENTER to type on a new line, or "
"EXIT to quit."
<< std::endl;
std::cin.ignore();
while (getline(std::cin, input)) {
if (input != "EXIT") {
f = output.print(input);
} else {
break;
}
};
output.closefile();
// splitstring here to check for new line
// getline automatically starts newline
if (f == true) {
std::cout << "Text succesfully written." << std::endl;
} else {
std::cout << "ERROR: Text failed to write." << std::endl;
return main(argc, argv);
}
} else {
std::cout
<< "Please enter the phrase write or read for your choice. No "
"spaces allowed."
<< std::endl;
return main(argc, argv);
}
}
}
}