generated from CSCI200/Template
close secretMessage
This commit is contained in:
parent
d3173832fd
commit
6920e0c6f9
1 changed files with 25 additions and 24 deletions
49
main.cpp
49
main.cpp
|
@ -10,31 +10,32 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
std::ifstream secretMessage("secretMessage.txt");
|
std::ifstream secretMessage("secretMessage.txt");
|
||||||
if (secretMessage.fail()) {
|
if (secretMessage.fail()) {
|
||||||
std::cerr << "Error opening secretMessage.txt file" << std::endl;
|
std::cerr << "Error opening secretMessage.txt file" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::ofstream decipheredMessage("decipheredMessage.txt");
|
std::ofstream decipheredMessage("decipheredMessage.txt");
|
||||||
if (decipheredMessage.fail()) {
|
if (decipheredMessage.fail()) {
|
||||||
std::cerr << "Error opening decipheredMessage.txt" << std::endl;
|
std::cerr << "Error opening decipheredMessage.txt" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char currentChar;
|
char currentChar;
|
||||||
while (secretMessage.get(currentChar)) {
|
while (secretMessage.get(currentChar)) {
|
||||||
switch (currentChar) {
|
switch (currentChar) {
|
||||||
case '\n':
|
case '\n':
|
||||||
decipheredMessage << std::endl;
|
decipheredMessage << std::endl;
|
||||||
break;
|
break;
|
||||||
case '~':
|
case '~':
|
||||||
decipheredMessage << ' ';
|
decipheredMessage << ' ';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
decipheredMessage << (char)(currentChar + 1);
|
decipheredMessage << (char)(currentChar + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
decipheredMessage.close();
|
secretMessage.close();
|
||||||
|
decipheredMessage.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue