Skip to content

Commit

Permalink
small fix to database
Browse files Browse the repository at this point in the history
  • Loading branch information
austinhutchen committed May 28, 2023
1 parent c7ffd50 commit c343fda
Show file tree
Hide file tree
Showing 4 changed files with 161,997 additions and 93 deletions.
Binary file modified a.out
Binary file not shown.
130 changes: 52 additions & 78 deletions driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,90 +5,64 @@ using namespace std;

int main(int argc, char **argv) {
string buf;
if(argc<2){
while(1){
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;
}
cout << "READ/ENCRYPT or WRITE to file in.txt?" << endl;
getline(cin, buf);

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 << "Would you like to write, or read from this file? Type WRITE "
"for write, CLEAR to delete a file,and READ for read. Type "
"LEAVE to exit program."
<< std::endl;
std::cin >> choice;
if (!std::cin.fail()) {
if (output.lowercase(choice) == "write") {
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;
}
};
// 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 if (output.lowercase(choice) == "read") {
output.readfile();
std::cout << "Would you like to edit this file? y/n" << std::endl;
std::cin >> choice;
if (choice == "y" || choice == "Y") {
std::cout << "Enter the number of the line that you wish to edit."
<< std::endl;
std::cin >> line;
if (!std::cin.fail()) {
output.edit(line);
// here is where the editing happens, will return a value based on
// edit success
} else {
std::cout << "ERROR" << std::endl;
}
}
} else if (output.lowercase(choice) == "clear") {
output.deletefile();
} else if (output.lowercase(choice) == "leave") {
return -1;
if (buf == "read" || buf == "encrypt") {
tester *help = new tester();
help->encryptalgo();
delete help;
help = nullptr;
return 0x0;
}

} else {
std::cout << "Please enter the phrase write or read for your choice. No "
"spaces allowed."
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;
return main(argc,argv);
}
std::cin.ignore();
while (getline(std::cin, input)) {
if (input != "EXIT") {
f = output.print(input);
} else {
break;
}

output.closefile();
}
};
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);
}


}
}
}

}
2 changes: 2 additions & 0 deletions txt/in.txt
Original file line number Diff line number Diff line change
Expand Up @@ -424,3 +424,5 @@ Etiam tempor orci eu lobortis elementum nibh tellus molestie nunc. Tortor at auc

© 2015 — 2023

here is the test screipt
ellooooo
Loading

0 comments on commit c343fda

Please sign in to comment.