Name: Anonymous 2009-02-25 16:06
Trying to get my Caesar cipher program to work. I need it to read from a file and output the encrypted file. Can anyone help me get it up and running. Thanks in advance.
#include <iostream>
#include <fstream>
#include<iostream>
int main ()
{
cout<<"Enter file name:";
string fname;
cin>> fname;
ifstream infile (fname.c_str());
encrypt(fname)
}
return 0;
}
char encrypt(char input)
{
int offset = 3, value; //initializing and declaring variables
char output;
if (input >= 'A' && input <= 'Z') //defining character scope
for encryption
{
value = (int)input - 65; //converting the character to ASCII
value += offset; //adding the offset
value %= 26; //modding the value
value +=65;
output = (char)value; //casting the integer ASCII value to a character
}
else
output = input; //if a character is not within the character scope then leave it as is
return output; //return the encrypted character
}