From your instructions, you want to add the value '5' to each character within your string. To decrypt, you'd simply do a -=5 in lieu of the +=5. You're encoding each character within the string, at least that's how I'm reading the problem. As example, a file such as;
I like apples.
I like pears.
I don't like carrots.
would encrypt to;
N%qnpj%fuuqjx3
N%qnpj%ujfwx3
N%its,y%qnpj%hfwwtyx3
Code:
int main()
{
ifstream dataFile;
ofstream encpFile;
std::cout << "Opening File....\n";
dataFile.open("plain.txt",ios::in);
std::string s;
encpFile.open("encrypt.txt", ios::out);
while(std::getline(dataFile, s, '\n'))
{
for(int x = 0; x<s.length(); x++)
{
s[x]+=5;
encpFile<<s[x];
}
encpFile<<"\n";
}
std::cout<< "we're done.";
std::cin.get();
dataFile.close();
encpFile.close();
return 0;
}