Hello! I am having some trouble with reading data for a list. If at the end of the file there is a new line character, this function reads the last set of data again, and then exits the loop. The addElem function works fine, I tested it separately. As there is almost impossible for me to generate a such text file without putting a new line character at the end of the file, i would like to know if there is a method to skip the new line character.
void aClass::readData(string filename)
{
string name;
string surname;
string address;
int type;
float count;
float cost;
ifstream f;
f.open(filename);
aList.clear();
id = 1;
while (!f.eof())
{
f>>name>>surname>>address>>type>>count>>cost;
this->addElem(name,surname,address,type,count,cost);
}
f.close();
}