temp file

HeiHon heiko.honrath at gmx.de
Sat Feb 18 04:18:23 PST 2012


On Saturday, 18 February 2012 at 10:19:06 UTC, bioinfornatics 
wrote:
> import std.string;
> import std.stdio;
>
> void main(  ){
>     File tmp = File.tmpfile();
>     tmp.writeln( "ok" );
>     tmp.writeln( "D is Fun" );
>     writefln( "fileName: %s", tmp.name );
>     foreach( line; tmp.byLine() )
>         writefln( "l: %s", line );
> }
...
> why i can not iterate over line?

You can, but the file is still open and you are at the end of the 
file.

Try:
      tmp.rewind;
      foreach( line; tmp.byLine() )
          writefln( "l: %s", line );




More information about the Digitalmars-d-learn mailing list