Instead of
while ( !indata.eof() )
{
indata >> EmployeeInfo[employee_count].set_first_name();
cout << EmployeeInfo[employee_count].get_first_name();
// etc
} try doing this;
string temp;
while ( !indata.eof() && employee_count < MAX_EMPLOYEE_SIZE)
{
indata >> temp;
EmployeeInfo[employee_count].set_first_name(temp);
cout << EmployeeInfo[employee_count].get_first_name();
// etc
} The additional check of employee_count stops running off the end of the array.
It is often a poor idea to use a float or double to represent currency figures. Particularly things like using 27.12 to represent $27 and 12 cents, as a floating point variable cannot represent 0.10 or 0.01 (or most combinations thereof) exactly. If you're only going to work with currencies that are dollars and cents, use a struct that represents the dollars and cents as separate fields, and manage the entries accordingly.
grumpier
Posting Whiz in Training
211 posts since Aug 2008
Reputation Points: 193
Solved Threads: 32