Reading stdin in Windows 7

Stanislav Blinov blinov at loniir.ru
Tue Aug 17 03:41:29 PDT 2010


  Hello,

I'm receiving strange results with reading stdin on Windows 7. Consider 
this code:

module test;

import std.stdio;

void main(string[] args)
{
         foreach (int i, string line; lines(stdin))
         {
                 write(line);
         }
}

On Linux, if I do 'cat test.d | ./test' I get test.d contents on stdout. 
But on Windows 7, ('type test.d | ./test.exe') the output is this:

std.stdio.StdioException: Bad file descriptor
module test;

import std.stdio;

void main(string[] args)
{
         foreach (int i, string line; lines(stdin))
         {
                 writef(line);
         }
}

So I too get type.d contents on stdout, but preceeded by StdioException 
string. This happens with dmd 2.047 and 2.048.

Is this my error, dmd's, or Windows's piping?
-- 

	

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20100817/82a3adc7/attachment.html>


More information about the Digitalmars-d-learn mailing list