Okay, I've seen answers on here but I still don't understand exactly what I need to do. I am trying to read in stuff from a file but I'm getting unexpected results with .eof() and I'm becoming frustrated with it! I cut out the stuff I'm actually doing for a project I'm doing but hopefully the code I have is enough for help. I have a bunch of similar while loops in my functions as I'm trying to parse data from a file and assign the data to the correct data structures. It seems to work when it wants too as one file I was testing works, while another says it reaches the end of the file when in reality it has one more piece of data to read. I don't know what's going on. Thank you ahead of time for the help!
void ReadStuff(ifstream &theFile)
{
while (!theFile.eof())
{
string line;
getline(theFile, line);
istringstream read(line);
string lineSect;
while (!read.eof())
{
read >> lineSect;
if (read.eof())
{
break;
}
//Reading stuff for this line
}
//Reading more stuff from a file until all data for all labels is read
}
}