ive made a program to read a input file and outputthe information, but now im having trouble making the program loop until eof
for this program there was only 1line in the input file for example
Andrew 5.00 30.00<---name payamount and hours
now there are about 15 more employees in the text file and the program should loop to read all and output into output file until eof
could someone help or point me in right direction
thanks
Code:
# include <string>
# include <iostream>
# include <fstream>
# include <iomanip>
using namespace std;
int main ()
{
ifstream inFile ;
ofstream outFile ;
string name ;
double rate;
double hours;
double pay;
//Open File
inFile.open ("\\emp.dat");
outFile.open ("\\empout.out");
inFile>>name>>rate>>hours;
//calculation for pay is made
pay =static_cast <double>(rate * hours);
//outFile display
outFile<<"LABOUR PRODUCTIONS "<<endl;
outFile<<"--------------------------------------"<<endl;
outFile<<setw(6)<<"Emp Name "<<setw(6)<<"Rate "<<setw(6)<<"Hours "<<setw(6)<<"Pay Amount "<<endl;
outFile<<"--------------------------------------"<<endl;
outFile<<fixed<<showpoint<<setprecision(2)<<setw(6)<<name<<setw(9)<<rate<<setw(8)<<hours<<setw(9)<<pay<<endl;
//close file
inFile.close();
outFile.close();
return 0;
}
for this program there was only 1line in the input file for example
Andrew 5.00 30.00<---name payamount and hours
now there are about 15 more employees in the text file and the program should loop to read all and output into output file until eof
could someone help or point me in right direction
thanks