g++ compiler errors:
encrpyt.cpp: In function ‘int main()’:
encrpyt.cpp:24:35: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive]
encrpyt.cpp:11:6: error: initializing argument 1 of ‘void doencrypt(char, char)’ [-fpermissive]
encrpyt.cpp:24:35: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive]
encrpyt.cpp:11:6: error: initializing argument 2 of ‘void doencrypt(char, char)’ [-fpermissive]
encrpyt.cpp:28:36: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive]
encrpyt.cpp:12:6: error: initializing argument 1 of ‘void dodecrypt(char, char)’ [-fpermissive]
encrpyt.cpp:28:36: error: invalid conversion from ‘char*’ to ‘char’ [-fpermissive]
encrpyt.cpp:12:6: error: initializing argument 2 of ‘void dodecrypt(char, char)’ [-fpermissive]
encrpyt.cpp: In function ‘void dodecrypt(char*, char)’:
encrpyt.cpp:85:30: error: invalid conversion from ‘char’ to ‘const char*’ [-fpermissive]
In file included from encrpyt.cpp:2:0:
/usr/include/c++/4.7/fstream:629:7: error: initializing argument 1 of ‘std::basic_ofstream<_CharT, _Traits>::basic_ofstream(const char*, std::ios_base::openmode) [with _CharT = char; _Traits = std::char_traits<char>; std::ios_base::openmode = std::_Ios_Openmode]’ [-fpermissive]
encrpyt.cpp:89:13: error: statement cannot resolve address of overloaded function
encrpyt.cpp:90:15: error: statement cannot resolve address of overloaded function
code:
#include <iostream>
#include <fstream>
using std::cout;
using std::cin;
using std::endl;
using std::ifstream;
using std::ofstream;
int menu();
void encrypt(ifstream&,ofstream&);
void decrypt(ifstream&, ofstream&);
void doencrypt(char,char);
void dodecrypt(char,char);
int main () {
int ans=menu();
char inputfile[100];
char outputfile[100];
char outputfile2[100];
while (ans != 3) {
if (ans ==1) {
cout << "Enter input file name." <<endl;
cin >>inputfile;
cout << "Enter output file name." <<endl;
cin >> outputfile;
doencrypt(inputfile, outputfile);
} else if (ans==2) {
cout << "Enter outputfile2 name"<<endl;
cin >>outputfile2;
dodecrypt(inputfile, outputfile2);
} else if (ans!=3) {
cout << "Sorry that is not a valid menu choice." <<endl;
ans=menu();
}
}
}
void encrypt (ifstream& input, ofstream& output) {
if (input && output) {
while (!input.eof()) {
char c;
input.get(c);
c +10;
output.put(c);
}
} else {
cout << "Input or output file does not exist" <<endl;
}
}
void decrypt (ifstream& input, ofstream& output2) {
if (input && output2) {
while (!input.eof()) {
char c;
input.get(c);
c-10;
output2.put(c);
}
} else {
cout <<"Input or output file does not exist" <<endl;
}
}
int menu () {
int pick;
cout << "Pick your menu choice : " <<endl;
cout << "1.Apply cipher to file" <<endl;
cout << "2.Decrypt cipher"<<endl;
cout <<"3.Quit"<<endl;
cin >> pick;
return pick;
}
void doencrypt (char inputfile[], char outputfile[] ) {
ifstream input(inputfile);
ofstream output(outputfile);
encrypt(input, output);
input.close();
output.close();
}
void dodecrypt(char inputfile[], char outputfile2) {
ifstream input(inputfile);
ofstream output2(outputfile2);
decrypt(input,output2);
input.close;
output2.close;
}