nocreate is not a member of std::ios

ios::nocreate是在C++标准制定之前在 <fstream.h> 中有定义的。


// void main()
int main()
string str;
cin > > str;
// you should check if <str> is a valid file name here
// ifstream fin;
fstream fs(str.c_str(), ios_base::in); // open file for reading
if (!fs) // file not exist
// do nothing
else // file exists. close and re-open for writing
fs.close();, ios_base::out); // reopen for writing

Leave a Reply

Your email address will not be published.