Hi,
I have many times experienced the following problem. I am reading from a file like this:
Now if the file SomeFile contains a blank line at its end (or several of those), and we have read the last number (or whatever) from it, the SomeFile.eof() will not report EOF, because there is still one or more blank lines left. But when in the next loop it tries to read from the file, it fails, because there is no values left in the file.Code:while(!SomeFile.eof()) { SomFile>>Param; }
Is there any smart way to avoid this problem?
It's not like it matters much, but it gets on my nerves each time my programme crashes just out of the blue and I can't find what's the matter. And then, after 20 minutes of debugging, I finally take a look at the input file to find out that, "Dah... I left a blank line at the end of the file...." Kind of annoying hehe
Thanks a lot!