Testing if file is there or not
I'm converting my old code to be compilable by DevC++, and the one thing which is not working is the ifstreamfail() command as follows:
ifstream GameFile("myGame.sav"); // *.sav is standard text file
if(GameFile.fail()) {
... create new character ...
} else {
... start game with current character ...
}
any suggestions?
Try this:
This is what I useualy do, and it always worked for me.
std::fstream str("myGame.sav"); if (str) // file is there else { // no file }
This is what I useualy do, and it always worked for me.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement