Basically I am attempting to open the player file to see if it exists first, if it does then it will send a command to the client telling them the username is taken, close the file and then return. Here is where it gets weird. First off, even if the file doesn't exist then it will create it, which is not what I want and not what I expected to happen(according to an example I found on this forum). Okay, so it creates the file when it opens it, thus the if check if(exists) is true and it sends the command of the msgbox, closes the file... but does not return. It continues on after the if statement and proceeds to open/create the file and fill it with the player's information... which it should never get to.
So.. what exactly is going on here? And how can I check if a file exists in C++(i.e. not using FILE *file). Any help or insight would be greatly appreciated.
Or std::ios::_Nocreate (I'm not sure if this is the correct. This reference has a suspicious lack of this flag) to the second constructor parameter for 'exists'.
If you are using an older C++ compiler (usually indicated by having to #include <iostream.h>) or Microsoft's VC++, you'll have to use the deprecated ios::nocreate flag. To work with both standards-compliant compilers and VC++, change line 3 to read:
Visual C++ recognizes _Nocreate but unfortunately the compiler that I am using to compile the code with does not recognize it and says that it is not a member of std::ios.. :\
Duoas, I just read your reply after I made my previous post. Thank you very much for the information, I haven't tried it yet but it seems like it will work great. Thanks again, and thank you helois as well.