Okay, so I loop through a file like this:
while(file->good()) {...}
good() returns true if none of the ifstreams error flags are set. Now, assume that that loop is inside a larger loop so that I am reading the entire file multiple times in succession. First I would obviously have to set the get pointer back to the beginning of the file, but I would also need to clear the error flags. If you don't do this good() will immediately evaluate to false because the eof (end of file) flag is still set from the previous iteration.
Now, I have tried multiple ways to clear these error flags and the only way that I have come up with that works is to delete the ifstream object and create a new one every time I want re-read the file, which is obviously not optimal.
I have tried using clear() but that just does not work, at least it is not working as I would expect it to...
while(file->good()) {...}
good() returns true if none of the ifstreams error flags are set. Now, assume that that loop is inside a larger loop so that I am reading the entire file multiple times in succession. First I would obviously have to set the get pointer back to the beginning of the file, but I would also need to clear the error flags. If you don't do this good() will immediately evaluate to false because the eof (end of file) flag is still set from the previous iteration.
Now, I have tried multiple ways to clear these error flags and the only way that I have come up with that works is to delete the ifstream object and create a new one every time I want re-read the file, which is obviously not optimal.
I have tried using clear() but that just does not work, at least it is not working as I would expect it to...