同时,编译一个包,在 RHEL 5.0 上用 C++ 编写。我收到以下错误。
> 错误:nocreate
不是 std::ios
的成员
源代码对应于:
ifstream tempStr(
argv[4]
,ios::in
|ios::nocreate
);
我试过了
#g++ -O -Wno-deprecated <file.cpp> -o <file>
还有:
#g++ -O -o <file>
请提出解决方案。
最佳答案
ios::nocreate
不是标准 C++ 的一部分 - 您希望它做什么?
编辑:从谷歌看来,它似乎是为了防止创建文件,如果它不存在的话。无论如何,这是 ifstreams 的默认设置,因此您可以说:
ifstream f( filename );
if ( ! f.is_open() ) {
// open failed - probably because infput file does not exist
}
关于c++ - 编译 C++ 代码时出现 ios::nocreate 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1062861/