I'm having an issue with an end of file while loop.
I have narrowed a problem with a previous program into a smaller bit of code and the error is in the read in and i hove no idea what to do about it... I have done this kind of thing before but never with the set spaced char variable so that has to be it.
#include <iostream>
#include <iomanip>
#include <fstream>
using namespace std;
main()
{
//definition of the variables for the program
ifstream infile;
ofstream outfile;
char name[15];
int planmin, usedmin, fivecount, thoucount, twothoucount, bonustotal, bonusmin, quotamin, quotatot, mintotal, users;
float average;
//opening of the input and putput files
infile.open("Sell_U_R.dat");
if (infile.fail())
{
cout << "The input file cannot be located" << endl;
exit(1);
}
outfile.open("test_output.out", ios::out);
if (outfile.fail())
{
cout << "The output file could not be created" << endl;
exit(1);
}
outfile << fixed << setprecision(0);
//while loop to read the
while(!infile.eof())
{
infile.getline(name,15);
infile >> planmin >> usedmin;
outfile << name << " " << planmin << " " << usedmin << endl;
}
infile.close();
outfile.close();
system("pause");
return 0;
}
I've just tried to output what I've input and its not working correctly so I'm not sure what I've done wrong with the read in
I'm getting an infinite loop of output but with an input file that looks like
W. Jones 1000 1250
Bud Wilson 2000 2075
Jim Jones 500 2873
Andre T. Lui 1000 824
I'm getting
W. Jones 2 0
2 0
2 0
2 0
2 0
2 0
2 0