i am writing a decryption program that reads a file from another project solution and decrypts it then writes it to a new file in its own project folder. For some reason when i try and read the file in the program says that file doesn't exist. Im pretty sure its not the path because i select the file i want to take the information from and i got its path from its properties. I dont know what might be wrong. Here is my code:
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
const int SIZE = 61;
char fileName[SIZE];
fstream inFile ("C:\Users\Chris\Documents\Visual Studio 2008\Projects\ChrisCaldwell_Ch12_Encrypt\ChrisCaldwell_Ch12_Encrypt\nameEncrypt.txt", ios::in | ios::out);
char ch;
ofstream outFile("newName.txt");
/*cout << "Please give the name for the file to be decrypted?";
cin >> fileName;*/
//inFile.open("C:\Users\Chris\Desktop\ChrisCaldwell_Ch12_Encrypt\ChrisCaldwell_Ch12_Encrypt\nameEncrypt.txt", ios::in);
if(!inFile)
{
cout << "Cannot open the file. Sorry!!!" << endl;
return 0;
}
inFile.get(ch);
while(!inFile.eof())
{
outFile.put((ch - 5));
inFile.get(ch);
}
inFile.close();
outFile.close();
cout << "File decryption is done.\n";
return 0;
}