I am working on a program to "encrypt" a text file supplied by the user, and writing to another file also given by the user. I am very new to programming and am having trouble passing information from file to program and back to file. I am close, but I have comiler errors. Here is my code so far:
To which I receive these following compiler errors:
Here (Photo)
any help would be useful, thanks
Code:
#include <iostream>
#include <cctype>
#include <fstream>
#include <iomanip>
using namespace std;
//Function: displayHeader
//Description: Outputs program header to screen
//Inputs: None
//Outputs: Header to screen
//Usage: displayHeader()
void displayHeader();
void getFile(char& fileIn, char& fileOut);
char charShift (char toEncrypt);
char encrypt(char symbol);
bool firstHalf(char symbol);
int main()
{
char fileIn[13];
char fileOut[13];
char runAgain;
ifstream file1;
ofstream file2;
displayHeader();
do
{
void getFile(char& fileIn, char& fileOut);
ifstream file1(fileIn[]);
if (!file1||!file2)
{
cout << "Error opening input file." << endl;
}
char encrypt(file1);
file1.close;
file2.close;
cout << "Would you like to run program again? (y/n)" << endl;
cin >> runAgain;
}
while (runAgain=='Y'||runAgain=='y');
}
void getFile(char& fileIn, char& fileOut)
{
cout << "Please enter name of file to be encrypted." << endl;
cin >> fileIn;
cout << "Please enter file to write to." << endl;
cin >> fileOut;
}
char encrypt(char symbol)
{
char encryptChar;
char nextCh;
nextCh=symbol;
file1.get(nextCh);
while (!file1.eof())
{
if (isalpha(nextCh))
{
encyptChar=charShift(nextCh);
file2 << encryptChar;
}
else
{
file2 << nextCh;
}
}
}
char charShift(char toEncrypt)
{
if (firstHalf(toEncrypt))
{
return toEncrypt+13;
}
else
{
return toEncrypt-13;
}
}
bool firstHalf(char symbol)
{
if((symbol>='A'&&<='M')||(symbol>='a'&&<='m'))
{
return 1;
}
else
{
return 0;
}
}
Here (Photo)
any help would be useful, thanks
Comment