igour - 2017-06-07

whenever i try to compile this program i get the following errors:
[Error] conflicting declaration 'std::ifstream inf'
[Error] 'inf' has a previous declaration as 'FILE inf'
[Error] request for member 'open' in 'inf', which is of pointer type 'FILE

[Error] request for member 'read' in 'inf', which is of pointer type 'FILE*

I just can't figure out how to resolve this. Can anyone help? here's my code:

include "enigma.h"

include <algorithm>

include <iostream>

include <vector>

enigma::enigma() {

}

enigma::~enigma() {
for(int i=0; i<num_rotors; i++)
delete []rotors[i];

delete []rotors;
delete []position;

}

int enigma::FileSize(const char* sFileName)
{
ifstream f;
f.open(sFileName, ios_base::binary | ios_base::in);
if (!f.good() || f.eof() || !f.is_open()) { return 0; }
f.seekg(0, ios_base::beg);
ifstream::pos_type begin_pos = f.tellg();
f.seekg(0, ios_base::end);
return static_cast<int>(f.tellg() - begin_pos);
}

int enigma::file_do_cipher(char * infile, char * outfile, char * key)
{
init_enigma(key);
FILE inf, of;
struct stat results;

int fsize = FileSize(infile);

if (stat(infile, &results) != 0) {
  printf("Cannot open file, quitting \n");
  exit(1);
}
inf = fopen(infile, "rb");
of = fopen(outfile, "wb+");

int filesize = results.st_size;

uint8_t x;
int p=0;

ifstream inf;
inf.open(infile, ifstream::in|ifstream::binary);
ofstream outf;
outf.open(outfile, ofstream::out|ofstream::binary);

if(!inf) {
    printf("An error occured opening the file!\n");
    return 1;
}

char y;

while(p<fsize)
{
for(int i = 0; i<fsize; i++)
{
    while(p<fsize)
    {
        inf.read(&y, 1);
        y = char_do_enigma((uint8_t) y);
        outf.write(&y, 1);
        p++;
    }
}
}
printf("encrypted/decrypted characters: %d\n", p);

}