In addition to the above changes, the following functions, constants, and enumerators that are elements of the old iostream library are not elements of the new iostream library:
- attach member function of filebuf, fstream ifstream, and ofstream
- fd member function of filebuf, fstream ifstream, and ofstream
- filebuf::openprot
- filebuf::setmode
- ios::bitalloc
- ios::nocreate
- ios::noreplace
- ios::sync_with_stdio
- streambuf::out_waiting
- streambuf::setbuf (use rdbuf -> pubsetbuf for the same behavior)
what's the .net replacement for ios::nocreate
"John Harrison" <> wrote in message news:<>...
> > In the new VC++ 7.0 ios::nocreate is obsolete. Does any one know what
> > I should do to achieve the same goal? I really want to check if a
> > file exists before reading from it.
> >
>
> There is no need for nocreate. If you open a file for reading and the file
> doesn't exist, then the open will fail. Nocreate is the default if you like.
所以不用nocreate也是可以的
在C++中
#include <fstream>
#include <iostream>
using namespace std;
使用ios::nocreate会报告错误:
error C2039: 'nocreate' : is not a member of 'basic_ios<char,struct std::char_traits<char> >'
error C2065: 'nocreate' : undeclared identifier
执行 cl.exe 时出错.
在C中
#include<fstream.h>
#include<stdlib.h>
可以直接使用
原因在于
ios::nocreate是在C++标准制定之前在<fstream.h>中有定义的。但是因为它跟系统平台相关密切,所以在C++标准中去掉了对它的支持。