eof() function not working c++ stuck with infinite loop [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: Why is iostream::eof inside a loop condition considered wrong? im having a problem with the eof() function. my loop is not reading the end of the file that im reading from thus leaving me with an infinite loop. Any help or insight would be greatly appreciated. thanks while (!file2.eof()) { getline (file2, title, ','); getline (file2, authorf, ','); getline (file2, authorl, ','); getline (file2, isbn, ','); file2