I've been workingo n this for a long time so I figured it's time to ask a question as I have no idea what's going on. For whatever reason in this loop, it only works proper through the first time, then it goes back to the beginning of the file and starts to read from the beginning again. Thanks.
void readGasFile(int numTherms, int arrSize, string fileName, Customer cArray[])
{
cout << "reading gas file";
int i;
string temp;
int temp2;
ifstream inputFile;
inputFile.open(fileName.c_str());
if (inputFile.is_open())
{
cout << "reading input file";
string dummyLine;
getline(inputFile, dummyLine);
//ignore first line
/* *****************************************
format:
1212 <--- account number
Lance, Ahmed
1200 1212 <----- previous, current therms meter readings
2323 <----- gas therms used
******************************************/
for(i=0; i<arrSize; ++i)
{
cout << "start loop" << i << endl;
inputFile >> temp2;
cArray[i].setNumber(temp2);
cout << temp2 << endl;;
inputFile >> temp;
cArray[i].setLastName(temp);
inputFile >> temp;
cArray[i].setFirstName(temp);
inputFile >> temp2;
cArray[i].setPrevious(temp2);
inputFile >> temp2;
cArray[i].setCurrent(temp2);
inputFile >> temp2;
cArray[i].setTherms(temp2);
}
}
return;
}