2024-09-21 20:22:26 -06:00
|
|
|
/**
|
|
|
|
* @file main.cpp
|
|
|
|
* @author Tyler Beckman (tyler_beckman@mines.edu)
|
|
|
|
* @brief CSCI200 L3A - A program to decipher an encoded message about cows
|
|
|
|
* @version 1
|
|
|
|
* @date 2024-09-21
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <fstream>
|
2024-09-21 18:30:11 -06:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
int main(void) {
|
2024-09-25 14:08:33 -06:00
|
|
|
std::ifstream secretMessage("secretMessage.txt");
|
|
|
|
if (secretMessage.fail()) {
|
|
|
|
std::cerr << "Error opening secretMessage.txt file" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2024-09-21 20:22:26 -06:00
|
|
|
|
2024-09-25 14:08:33 -06:00
|
|
|
std::ofstream decipheredMessage("decipheredMessage.txt");
|
|
|
|
if (decipheredMessage.fail()) {
|
|
|
|
std::cerr << "Error opening decipheredMessage.txt" << std::endl;
|
|
|
|
return -1;
|
|
|
|
}
|
2024-09-21 20:22:26 -06:00
|
|
|
|
2024-09-25 14:08:33 -06:00
|
|
|
char currentChar;
|
|
|
|
while (secretMessage.get(currentChar)) {
|
|
|
|
switch (currentChar) {
|
|
|
|
case '\n':
|
|
|
|
decipheredMessage << std::endl;
|
|
|
|
break;
|
|
|
|
case '~':
|
|
|
|
decipheredMessage << ' ';
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
decipheredMessage << (char)(currentChar + 1);
|
|
|
|
}
|
|
|
|
}
|
2024-09-21 20:22:26 -06:00
|
|
|
|
2024-09-25 14:08:33 -06:00
|
|
|
secretMessage.close();
|
|
|
|
decipheredMessage.close();
|
2024-09-21 18:30:11 -06:00
|
|
|
}
|