aboutsummaryrefslogtreecommitdiff
path: root/CST 126/Homework2/main.cpp
diff options
context:
space:
mode:
authorrPatrickWarner <[email protected]>2024-05-31 18:18:43 -0700
committerrPatrickWarner <[email protected]>2024-05-31 18:18:43 -0700
commit43ba28ac0abcceb14cd84fb3ff85259dab17592d (patch)
tree62defcabeef17d9b30c9254e9bc072b5df3514c2 /CST 126/Homework2/main.cpp
parentfinished homework3 (diff)
downloadhomework-1-reecepwarner-43ba28ac0abcceb14cd84fb3ff85259dab17592d.tar.xz
homework-1-reecepwarner-43ba28ac0abcceb14cd84fb3ff85259dab17592d.zip
fixing my homework2 project
Diffstat (limited to 'CST 126/Homework2/main.cpp')
-rw-r--r--CST 126/Homework2/main.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/CST 126/Homework2/main.cpp b/CST 126/Homework2/main.cpp
index 6ee3172..70ea255 100644
--- a/CST 126/Homework2/main.cpp
+++ b/CST 126/Homework2/main.cpp
@@ -30,7 +30,7 @@ bool Worker()
const char* Destination = nullptr;
char* buffer = nullptr;
size_t size = 0;
- buffer = new char[size];
+
char Option = '\0';
do
{
@@ -40,10 +40,10 @@ bool Worker()
switch (Option)
{
case 'e':
-
MyFile = InputFileName("What is the name of the file you wish to encode?: ");
Destination = InputFileName("\nWhat is the name of the file that you wish to save the encoded information?: ");
size = SizeOfFile(MyFile);
+ buffer = new char[size];
buffer = ReadFileAsBinary(MyFile, buffer, size);
success = WriteTextToFile(Destination, Base64Encode(buffer, size));
delete[] buffer;
@@ -53,7 +53,8 @@ bool Worker()
MyFile = InputFileName("What is the name of the file you wish to decode?: ");
Destination = InputFileName("\nWhat is the name of the file you wish to save the decoded information?: ");
size = SizeOfFile(MyFile);
- buffer = ReadTextFromFile(MyFile, buffer);
+ buffer = new char[size];
+ ReadTextFromFile(MyFile, buffer);
success = WriteFileFromBinary(Destination,buffer, Base64Decode(buffer, size));
return true;