Heres the problem I'm trying to take a file created from a previous program and add it to a link list, but it does not seem to make through the translator portion. It will go into a loop.
Any sugestions will be appreciated.
Alpha22
Code:
int translateBudrec()
{
int numErrors = 0; // holds return value of whether an error occurred
BudrecType5 inRec5; // this is a record to hold lab 5 data
BudrecType6 newRec6; //this is a record to hold lab 6 data
string fileName5;
string fileName6;
cout << "Enter the lab5 binary file to read:" << flush;
cin >> fileName5;
inFile.open(fileName5.c_str(), ios::binary);
cout << "Enter the lab6 binary file to create:" << flush;
cin >> fileName6;
outFile.open(fileName6.c_str(), ios::binary);
if (inFile && outFile){
inFile.read(reinterpret_cast<char *>(&inRec5), sizeof(inRec5));
cout << endl << "The rec 5 amount is: " << inRec5.catAmts << endl;
while (!inFile.eof()) {
strcpy(newRec6.catName, inRec5.catName);
newRec6.catAmts = inRec5.catAmts;
newRec6.catPcts = inRec5.catPcts;
newRec6.nextRec = NULL;
cout << "The rec 6 amount is: " << newRec6.catAmts << endl;
//after this line program goes into a loop repeating the rec 6 amount.
outFile.write(reinterpret_cast<char *>(&newRec6), sizeof(newRec6));
} // end while not end of file
} else {
cout << "File : " << fileName5.c_str() << " does not exist" << endl;
numErrors = 1;
}
inFile.clear();
outFile.clear();
inFile.close();
outFile.close();
return numErrors;
}//end translateBudrec