1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cstdlib>
#include "NBEmployee.h"
using namespace std;
int main (int argc, const char * argv[])
{
NBEmployeeMembers worker[4];
fstream inFile("employee_data_in.txt", fstream::in);
//fstream outFile("payroll_check.txt", fStream::out);
if (!inFile)//error message
{
cerr << "File could not be opened" << endl;
exit(1);
}
string empLastName;
char payrollType;
int hoursWorked,
payrate,
unionCode;
char * buffer;
inFile.seekg (0, ios::end);
int length = inFile.tellg();
inFile.seekg (0, ios::beg);
// allocate memory:
buffer = new char [length];
// read data as a block:
inFile.read (buffer,length);
cout.write (buffer,length);
int j = 0;
//this is where I need most help, i don't know how to pick out individual info
while (inFile >> empLastName >> payrollType >>
hoursWorked >> payrate >> unionCode )
{
worker[j].EmployeeSet(empLastName, payrollType, hoursWorked, payrate, unionCode);
j++;
}
for (int i = 0; i < 4; i++)
{
worker[i].printEmp();
}
inFile.close();
return 0;
}
|