可能重复问题:编译C++代码时出现ios::nocreate错误
我一直在研究如何在C++/C#中创建简单的词法编译器,但是当我尝试编译程序时,出现了一个错误:
error c2065 'nocreate' undeclared identifier
我该如何处理这个问题?但我认为可能与fstream头文件有关,你有什么想法可以处理吗?
这是代码导致错误的地方。
loadTransitionTable( );
fstream File("input.txt", ios::in|ios::Nocreate);
if (!File)
{
cout<<"\n Unable to open the input file."<<endl;
cout<<"\n Press any key to exit.";
getch( );
exit(0);
nocreate
标志?如果你使用ios::in
(默认值为ifstream
)打开文件,那么如果文件不存在就不会创建新文件。 - Some programmer dude