   c++, toubles with .fail() when reading in a file
  Sorry to post this but for some reasion this isn't working for me.I am using With:ins.open("space.cfg");//No file?if ( ins.fail() ){genConfig();MessageBox(NULL, "No config file, generating one for you", "No config file", MB_OK);    The only problem is when ever I do an .open(...) it creates a space.cfg so then it will never fail.  I could have sworn I was able to use .fail() a few years ago.Is there anything I'm doing wrong?[edited by - skow on February 4, 2004 5:19:39 PM]
  What type is "ins"? ;  Assuming you are talking about iostreams:ins.open("space.cfg", std::ios::nocreate);   ~nz   // Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions //   [edited by - neoztar on February 4, 2004 5:26:04 PM];  Sorry, ins is of type ifstreamWhat header do I need for std::ios::nocreate?  I have stdlib.h, iostream, and, fstream(.h) and am having no luck getting it to work. ;  i dont know if nocreate made it in C99    ;#include <ios>  quote:i dont know if nocreate made it in C99 It works with MSVC, but not with MinGW. So if you want it portable, try boost::filesystem::exists()   ~nz // Website // Google // GameDev // NeHe // MSDN // OpenGL Extensions // ;I included , it doesnt seem fo find nocreate,getsettings.cpp(35) : error C2872: ''ifstream'' : ambiguous symbolgetsettings.cpp(45) : error C2039: ''nocreate'' : is not a member of ''basic_ios >''getsettings.cpp(45) : error C2065: ''nocreate'' : undeclared identifier ;quote:Original post by DerAnged  i dont know if nocreate made it in C99You do realize that C99 refers to C, not C++, and that C does not have streams of any sort. ;  Ok never mind, I just added a check to see if the file is empty to relace the .fail call.Thanks for the help. 