I'm new to this forum as well as C++ in general, and I'm making a program that imports text from one file, changes it a bit, and then moves the changed text over to another file. Anyways, I didn't have much of a problem changing the text over, but the way that I tried to bring the newlines over didn't work, and I have no idea why. Thanks. I could really use some help.
char fileChars;
ifstream codedMessage;
ofstream decodedMessage;
cout << "Decoding File" << endl;
codedMessage.open("secretMessage.txt");
decodedMessage.open("decipheredMessage.txt");
if (codedMessage.fail() ) {
cerr << "Error..." << endl;
exit(1);
}
while (!codedMessage.eof()){
codedMessage >> fileChars;
if (fileChars == '\n') {
decodedMessage << "\n";
} else if (fileChars == '~') {
decodedMessage << ' ';
} else {
decodedMessage << ++fileChars;
}
}
cout << "Closing Files." << endl;
codedMessage.close();
decodedMessage.close();
Aucun commentaire:
Enregistrer un commentaire