I have an array of struct employee which I am trying to call in the function readFile.
I have tried using pointers to call but they all fail and give me the same error message.
#include <iostream>
#include <fstream>
using namespace std;
int readFile (ifstream *inFile, struct employee array[]);
int main () {
int size = 10;
struct employee {
string name;
int id;
float salary;
} array[size];
ifstream inFile;
readFile(&inFile, array);
return 0;
}
int readFile (ifstream *inFile, struct employee array[]) {
inFile->open("pay.txt");
if(inFile->fail()) {
cout << "fail";
exit(1);
} else {
cout << "success";
}
return 0;
}
The error message I get is this:
.cpp:16:25: error: cannot convert 'main()::employee*' to 'employee*' for argument '2' to 'int readFile(std::ifstream*, employee*)'
readFile(&inFile, array);
float(I could negotiate a raise to the next dyadic rational?). Your best bet is to work in cents when modelling money.