[RESOLVED] Problem opening blank files with ifstream
I'm having problems opening blank files with ifstream. It seems to be saving a blank line over my first string variable. For example I created a completely blank text file in notepad and saved it as SAVEGAME.DAT. I then try to open it with the following code.
1. [first line is blank]
2. empty
3. empty
4. Press any key to continue.
So somehow its saving over my first string variable even though the SAVEGAME.DAT file is completely blank
It works fine however if SAVEGAME.DAT has a line of text in it. When I open SAVEGAME.DAT and insert and save some text. For example if I save the word "sometext" in SAVEGAME.DAT. I get the following:
Code:
1. sometext
2. empty
3. empty
4. Press any key to continue.
This is working fine^ It only doesn't work right if the file is blank.
Here is updated code that works great for my save game function in my game just in case anyone has similar problems to this in the future and stumbles upon this on the google or something
Bookmarks