From 6920e0c6f9f5aa433479ec7e9705d468f43b4b470fa05cf792e7d047607a8107 Mon Sep 17 00:00:00 2001 From: Tyler Beckman Date: Wed, 25 Sep 2024 14:08:33 -0600 Subject: [PATCH] close secretMessage --- main.cpp | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/main.cpp b/main.cpp index bcee382..954153d 100644 --- a/main.cpp +++ b/main.cpp @@ -10,31 +10,32 @@ #include int main(void) { - std::ifstream secretMessage("secretMessage.txt"); - if (secretMessage.fail()) { - std::cerr << "Error opening secretMessage.txt file" << std::endl; - return -1; - } + std::ifstream secretMessage("secretMessage.txt"); + if (secretMessage.fail()) { + std::cerr << "Error opening secretMessage.txt file" << std::endl; + return -1; + } - std::ofstream decipheredMessage("decipheredMessage.txt"); - if (decipheredMessage.fail()) { - std::cerr << "Error opening decipheredMessage.txt" << std::endl; - return -1; - } + std::ofstream decipheredMessage("decipheredMessage.txt"); + if (decipheredMessage.fail()) { + std::cerr << "Error opening decipheredMessage.txt" << std::endl; + return -1; + } - char currentChar; - while (secretMessage.get(currentChar)) { - switch (currentChar) { - case '\n': - decipheredMessage << std::endl; - break; - case '~': - decipheredMessage << ' '; - break; - default: - decipheredMessage << (char)(currentChar + 1); - } - } + char currentChar; + while (secretMessage.get(currentChar)) { + switch (currentChar) { + case '\n': + decipheredMessage << std::endl; + break; + case '~': + decipheredMessage << ' '; + break; + default: + decipheredMessage << (char)(currentChar + 1); + } + } - decipheredMessage.close(); + secretMessage.close(); + decipheredMessage.close(); }