I use this when include fstream.hWhat should I write when using fstream? (with namespace)Code:ifstream obj(path,ios::nocreate)
In the case of ifstream, it is not necessary. If the file does not exist, the ifstream won't open it and won't create it. Just remove the flag and check obj.is_open after the constructor to verify that the file was opened or not.
I don't see why you'd want to force it to create a file if you are using an ifstream (which is for input files). If you are using an ofstream (for output files) or a plain fstream, then the file will be created automatically.
If you are using an ofstream and you don't want to create the file (which is what nocreate was likely used for), then you could just use an ifstream to open the file for reading. If that succeeds, then close it and open the file for writing with your ofstream. If the ifstream open fails, then the file doesn't exist.