Im doing c++ now in school, so I decided I should start doing some stuff at home. Im just messing around making a small program that will encrypt and decrypt text files, the only problem is Im getting an error for using the string a as the file path under the string file_content(string a); function.
Code:
#include "stdafx.h"
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
string encrypt(string a);
string decrypt(string a);
string file_content(string a);
void main(){
string content;
string file;
string input;
cout<<"Welcome to ascii encrypter and decrypter v1.0\n please enter the file you wish to encrypt or decrypt : ";
cin>>file;
cin.get();
cout<<"\n getting file content";
content = file_content(file);
}
string encrypt(string a){
for (int z =0;z<a.size();z++){
a[z] += 5;
}
return a;
}
string decrypt(string a){
for (int z =0;z<a.size();z++){
a[z] -= 5;
}
return a;
}
string file_content(string a){
string file;
string buffer;
ifstream b_file (a);
while ( !b_file.eof() ){
b_file>>buffer;
buffer += " ";
file += buffer;
}
b_file.close();
return file;
}