I am currently in an introduction to C++ course in college. Currently, they are having us use fstream to read from and write to files. (simple .txt files, nothing major)
My current problem is this. The program reads from a file of names, pay rates, and hours worked. I have a while loop detecting when the stream fails. When it does, the program finishes. However, the last records are duplicated, as if the stream re-reads the last line. Is there a way to prevent this from happening?
The function returns true if either the failbit or the badbit is set. At least one of these flags is set when some error other than reaching the End-Of-File occurs during an input operation.