Hi I have following loop for reading in persons:
void personFin(vector<Person>* persvect, string filename)
{
ifstream personfile(filename);
string name;
int lhstrength;
int rhstrength;
int erasiveskill;
int ID = 1;
cout << "reading in persons" << endl;
if (personfile.good())
{
while (!(personfile >> name).eof())
{
cout << "start read in " << ID << endl;
personfile >> lhstrength;
personfile >> rhstrength;
personfile >> erasiveskill;
Person temp(name, lhstrength, rhstrength, erasiveskill, ID);
persvect->push_back(temp);
cout << "end read in " << ID << endl;
ID++;
}
personfile.close();
}
else
{
cout << "ERROR: Cannot open file.\n";
}
}
I executed my program in Xcode and everything worked fine when I compile it with g++ the input file loop is infinite
thanks for your help