IM HAVING ISSUES GETTING A PROGRAM TO READ INFO FROM A FILE AND DOING THE FINAL OUTPUT. CAN SOMEONE HELP ME PLEASE...
//////////////////////////////////////////////////////////////////////////
// Get // Post: if employee number in filename is valid returns SUCCESS
// Employee // and employeeName, payRate and ytdGross
// FileData // else returns INVALID_FILE
// // and employeeName, payRate and ytdGross are undefinded
////////////// if file does not exist return FILE_NOT_FOUND
int GetEmployeeFileData( char filename[], char employeeNumber[],
char employeeName[], double& payRate, double& ytdGross )
{
// Read the data from the employee file and confirm that empFileNumber in
// the opened file is the same as the employeeNumber received from the user
char empFileNumber[32];
ifstream fin( filename );
if ( !fin ) {
return FILE_NOT_FOUND;
}//endif
fin >> empFileNumber;
if ( strcmp( employeeNumber, empFileNumber ) ) {
return INVALID_FILE;
}//endif
fin.ignore( 1 );
fin.getline( employeeName, ARRAY_MAX, '\t' );
fin >> payRate >> ytdGross;
// Use show to confirm that data was read from the employee file correctly
show( empFileNumber );
show( employeeName );
show( payRate );
show( ytdGross );
getch();
return false;
}//endfn GetEmployeeFileData
///////////////////////////////////////////////////////////////////////////
// // Post: if employee number in filename is valid
// GetHoursFileData // returns SUCCESS and number of hoursWorked
// // else returns INVALID_FILE and hoursWorked is undefined
////////////////////// if file does not exist returns FILE_NOT_FOUND
int GetHoursFileData( char filename[], char employeeNumber[], double& hoursWorked )
{
// Read the data from the hours file and confirm that hrsFileNumber in
// the opened file is the same as the employeeNumber received from the user
char hrsFileNumber[32];
ifstream fin( filenumber );
if ( !fin ) {
cerr << "File " << filenumber << " not found!";
getch();
return 1;
}//endif
// Use show to confirm that data was read from the hours file correctly
show( hrsFileNumber );
show( hoursWorked );
return false;
}//endfn GetHoursFileData