Compiling error I cannot locate
I'm getting an error and cannot figure out how to fix it
The error is in line 42: error: a function-definition is not allowed here before â{â token
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
#ifndef security_CFF
#define security_CFF
#include <iostream>
#include <vector>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
#include "hw1.h"
void security::driver()
{
cout << "--------------------" << endl;
cout << "1: Encrypt using rot" << endl;
cout << "2: Encrypt using crypto" << endl;
cout << "3: Decrypt using rot" << endl;
cout << "4: Decrypt using crypto" << endl;
cout << "Choose one of the options, 1-4" << endl;
cin >> numberPicked;
if((numberPicked!=1)&&(numberPicked!=2)&&(numberPicked!=3)&&(numberPicked!=4))
{
cout << "You entered an invalid number. Exiting program" << endl; //input error check
};
if(numberPicked==1)
{
cout<<"Please enter a RotNum: " << endl;
cin>>rotNum;
if((rotNum>26)||(rotNum<1))
cout << "You entered an invalid input. Exiting program" << endl; // input error check
else
{
cout << "Please enter the name of the file that needs to be encrypted using the rot method:"<<endl;
cin >> fileName;
encryptRot();
}
}
}
void security::encryptRot()
{
ifstream fin;
fin.open(fileName.data());
while(fin>>word)
{
E.push_back(word);
}//end fin>word
ofstream fout;
fout.open("encrypt01.txt");
for(int w=0; w<E.size(); w++)
{
eWord=E[w];
for(int i=0; i<eWord.size(); i++)
{
letter=eWord[i];
letter=tolower(letter);
if((letter<'a')||(letter>'z'))
letter=letter;
else
{
letter=letter+rotNum;
if(letter>'z')
{
letter=letter-26;
eWord[i]=letter;
};//end if letter > z conversion
else
eWord[i]=letter;
};//end each rotnum conversion
};//end eWord loop
D.push_back(eWord);
fout << D[w] << " ";
};//end E loop
}
|
I have all the variables initialized in a separate Class file. I could post that also if needed
Last edited on
Topic archived. No new replies allowed.