|
|
while(!fin.eof())
is incorrect, if you got this loop structure from a book, get rid of it (if it's from a teacher, well, no such luck)fin >> cof[k].productNum;
would compile, but it would be an error at runtime because when the vector is empty, it has no kth element.
|
|
while(!fin.eof())
does work. As you read in data from the file, the loop will continue until the file reaches the eof state. As for using getlines and operator >>'s, I'm trying to read lines of text in from a file and numbers.Well while(!fin.eof()) does work. As you read in data from the file, the loop will continue until the file reaches the eof state. |
The data in the text file would look like this: 1000 Western Brew |