eof

Ali Çehreli acehreli at yahoo.com
Tue Jun 25 21:46:28 PDT 2013


On 06/25/2013 09:26 PM, lx wrote:

 > Ctrl+z seems close the stream.So,if I want
 > to input another batch of data,it became impossilbe.So,how to reopen the
 > stream again to allow me to input another batch of data?

Making a copy of stdin works on Linux (where the stream is terminated by 
Ctrl-D in the console):

import std.stdio;
import std.algorithm;

void main()
{
     auto stdin_dup = stdin;

     stdin
         .byLine(KeepTerminator.yes)
         .copy(stdout.lockingTextWriter);

     writeln("done");

     stdin_dup
         .byLine(KeepTerminator.yes)
         .copy(stdout.lockingTextWriter);

     writeln("done again");
}

Ali



More information about the Digitalmars-d-learn mailing list