I need help with decrypting a 12 character message located in a file named encrypted.txt then printing the decrypted message to the screen and a new file named decrypted.txt. This is what i have so far... and don't understand how to print the char to the screen as a letter instead of the ASCII value when i subtract 3 to decrypt it. I am new to this so please try and keep it simple for me..also I'm using VS 2008 Express C++. Here is the encrypted text im using for an example...“UHWXUQWRURPH” which when decrypted is..“RETURNTOROME”, but I only get the ASCII values.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
char ch;
ifstream infile;
ofstream outfile;
infile.open("encrypted.txt");
outfile.open("decrypted.txt");
//test if file opens.
if (!infile)
{
cout << "Error: Can't open file \n";
return 1;
}
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch -3;
infile >> ch;
cout << ch -3;
infile >> ch;
cout << ch -3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile >> ch;
cout << ch - 3;
infile.close();
outfile.close();
return 0;
}