Heres file.h
Code:
#ifndef file_var
#define file_var
class file
{
public:
file();
~file();
void encrypt ();
void decrypt ();
char EncryptChar (char ch);
void EncryptString (char *str);
protected:
char file_one[256];
char file_two[256];
char contents[1000];
char key[5];
};
#endif
heres main_01.cpp
Code:
#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
#include "file.h"
file::file()
{
file_one="\0";
file_two="\0";
contents="\0";
key="\0";
}
char file::EncryptChar(char ch)
{
key[0] = key[1] + key[3];
key[4] = key[0] * key[2];
ch = key[4];
return ch;
}
void file::EncryptString(char *str)
{
while (*str != '\0') *str = EncryptChar(*str++);
}
void file::encrypt()
{
cout<<"Enter Files Name"<<endl;
cout<<":";
cin.getline(file_one, 256, '\n');
cout<<"Enter File to Save it to"<<endl;
cout<<":";
cin.getline(file_two , 256, '\n');
cout<<"Enter 5 Digit Key"<<endl;
cout<<":";
cin.getline(key, 5, '\n');
/* Open File */
ifstream ein;
ein.open(file_one);
while(ein.eof() != 1)
{
int x = 0;
x++;
ein>>contents[x];
}
/* Encrypt */
EncryptString(contents);
/* Save */
ofstream eout;
eout.open(file_two);
for(int x = 0; x != 1000; x++)
{
eout<<contents[x];
}
eout.close();
/* Finished */
cout<<"Encryption completed..."<<endl;
cout<<file_one<<" was encypted to "<<file_two<<endl;
cout<<"The key is "<<key<<endl;
Sleep(2500);
exit(0);
}
and when I try to compile it on borland 5.5 this happens:
! Error E2277 .\main_01.cpp 11: Lvalue required in function file::file()
! Error E2277 .\main_01.cpp 12: Lvalue required in function file::file()
! Error E2277 .\main_01.cpp 13: Lvalue required in function file::file()
! Error E2277 .\main_01.cpp 14: Lvalue required in function file::file()