File Ex from std_stdio won't compile
    Paul 
    phshaffer at gmail.com
       
    Wed Apr 18 05:09:20 PDT 2012
    
    
  
I copied the code below from this site under the std.stdio 
library reference section and tried to compile it.  I downloaded 
D2/Phobos.  Compiler says "fileread.d(4): Error: undefined 
identifier File"
If I add import std.stdio to the beginning it get ; expected, 
function declaration w/o return type, etc.
Assistance is greatly appreciated.
  void main(string args[])
{
     auto f = File("test.txt", "w"); // open for writing
     f.write("Hello");
     if (args.length > 1)
     {
         auto g = f; // now g and f write to the same file
                     // internal reference count is 2
         g.write(", ", args[1]);
         // g exits scope, reference count decreases to 1
     }
     f.writeln("!");
     // f exits scope, reference count falls to zero,
     // underlying FILE* is closed.
}
    
    
More information about the Digitalmars-d-learn
mailing list