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 <cstdlib>
#include <stdio.h> // FILE structure
#include <iostream>
using namespace std;
struct tDed {
public:
string dedDate, DedAmm, DateEntered;
};
struct tPayroll {
public:
double holidaypayindex;
string CommNum, RankName, LastName, FirstName, ReferenceNumber, Dist, TotalDue,
PaycheckDed, CCDate;
tDed DedDatesAndAmmts[];
unsigned char CDNum;
string LetterSent;
bool WasChecked;
};
string getname(string s);
int main(int argc, char *argv[])
{
cout << "Enter File Path: ";
string s;
getline(cin,s);
if (s[s.length() - 1 ] == '"') s.erase(s.length() - 1,s.length());
if (s[0] == '"') s.erase(0,1);
cout << "Name: " << getname(s) << endl;
system("PAUSE");
return 0;
}
string getname(string s){
int recordsRead;
char z[8];
FILE* f;
//ifstream f(s.c_str());
f = fopen(s.c_str(), "rb");
if (!f) exit(0);
recordsRead = fread(&z,7, 1,f);
//f.read (z, 7);
long x = 0;
for (int i = 0; i < 8; i++) if ( z[i]-'0' >= 0 && z[i]-'0' <= 9 ) x = x*10 + z[i]-'0';
tPayroll tp;
realloc(tp.DedDatesAndAmmts, x );
while ( recordsRead != 0 )
{
recordsRead = fread(&tp, sizeof(tp),1,f);
}
fclose(f);
// f >> (char *) &tp;
//f.read((char *) &tp, sizeof tp);
//cout << sizeof tp;
// f >> ctp;
// tp = (tPayroll*) &ctp;
// f.close();
return ( tp.LastName + ", " + tp.FirstName);
}
|