ios:nocreate

John Love-Jensen eljay@adobe.com
Fri Sep 27 12:09:00 GMT 2002


Hi Yu-Lun,

The ios::nocreate setting did not make it into the ISO 14882:1998 C++
standard.  Too platform specific.

You can simulate that behavior with:

fstream foo("foo.txt", ios_base::in);
if(!fs) {
  // File does not exist.
  // Do not create one.
  }
else {
  foo.close();
  foo.open("foo.txt", ios_base::out);
}

Note:  the ios::xxxxx settings are from the defunct <fstream.h> header file.
While the ios_base::xxxxx are from the <fstream> (notice, no .h suffix)
header file, within the std namespace.

--Eljay



More information about the Gcc-help mailing list