Search code examples
c++fstream

Using ios::Nocreate flag results in "undeclared identifier" error


Possible Duplicate:
ios::nocreate error while compiling a C++ code

i have been working on how to create a simple lexical compiler in c++/c# but it seems i have a an error when i try to compile the program the error is

error c2065 'nocreate' undeclared identifier 

how can i handle this problem??but im thinking maybe it has to do with the fstream header,any ideas on how i can handle it??

this is the code where it is giving me an error

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);

Solution

  • If you are with VisualStudio, try

    std::fstream File("input.txt", std::ios::in|std::ios::_Nocreate);