I dont mean to hijack the thread but maybe you could explain my problem as it seems to be on the same lines as jedi's. Basically i have written to a file and now im trying to read it back but when i do, i hit an infinite loop and the code breaks!!
I have put the IF statements before each print to try and solve the problem or atleast find where its breaking but to no luck!!Code:void inClientForm(customer* theRecord, int size) { char custname[20]; int age, purchaseCount; char gender[10]; float purchaseCost; ifstream inClientFile( "clients.txt", ios::in ); while(!inClientFile.eof()) { inClientFile.getline(custname,20); if (!inClientFile.eof()) cout << custname << endl; inClientFile >> age; if (!inClientFile.eof()) cout << age << endl; inClientFile.getline(gender,10); if (!inClientFile.eof()) cout << gender << endl; inClientFile >> purchaseCount; if (!inClientFile.eof()) cout << purchaseCount << endl; inClientFile >> purchaseCost; if (!inClientFile.eof()) cout << purchaseCost << endl; } }



LinkBack URL
About LinkBacks


