Originally Posted by
Daved
There's no point in opening a file for reading and creating it if it doesn't exist, so the ifstream doesn't do that. I'd check to see if the file opened. If it didn't then create with an ofstream. If it did, read it.
As far as your problem with eof(), it will never return true with a new file stream until after you've attempted to read. You have to do some read operation first, and that read operation has to attempt to read when there are no more characters, then eof() will be true.