www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - redirect input on windows

reply Carlos Santander <csantander619 gmail.com> writes:
Does anybody know if there's a trick to make DMD-generated programs to read
from 
a redirected input on Windows? I mean:

dmd foo
foo < input

I've been trying but I can't get it to work. I also get wrong (but different) 
behavior using dmc, visual c++ 2003 and lcc. However bcc, openwatcom and gcc 
work. Any ideas?

-- 
Carlos Santander Bernal
Oct 01 2005
parent reply =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Carlos Santander schrieb:
 Does anybody know if there's a trick to make DMD-generated programs to
 read from a redirected input on Windows? I mean:
 
 dmd foo
 foo < input
 
 I've been trying but I can't get it to work. I also get wrong (but
 different) behavior using dmc, visual c++ 2003 and lcc. However bcc,
 openwatcom and gcc work. Any ideas?
** echo input lines ** import std.c.stdio; import std.stdio; import std.cstream; int main(){ CFile f = new CFile(stdin, FileMode.In, false); for(char c=f.getc(); c!=0xFF; c = f.getc()){ writef("%s", c); } return 0; } **** Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDP38p3w+/yD4P9tIRAsE1AJ9aCPfEiRzva6NDCE5sRIxaBywxOACfV62u xPk3gcPpo0A39FwISV9fcV8= =1Lp4 -----END PGP SIGNATURE-----
Oct 01 2005
parent reply Carlos Santander <csantander619 gmail.com> writes:
Thomas Kühne escribió:
 
 Carlos Santander schrieb:
 
Does anybody know if there's a trick to make DMD-generated programs to
read from a redirected input on Windows? I mean:

dmd foo
foo < input

I've been trying but I can't get it to work. I also get wrong (but
different) behavior using dmc, visual c++ 2003 and lcc. However bcc,
openwatcom and gcc work. Any ideas?
** echo input lines ** import std.c.stdio; import std.stdio; import std.cstream; int main(){ CFile f = new CFile(stdin, FileMode.In, false); for(char c=f.getc(); c!=0xFF; c = f.getc()){ writef("%s", c); } return 0; } **** Thomas
Thanks, Thomas! That worked, but using din was enough. However, it's still not working with C. What's so different with DMC, Visual C++ and LCC that that doesn't work? -- Carlos Santander Bernal
Oct 02 2005
parent Carlos Santander <csantander619 gmail.com> writes:
Carlos Santander escribió:
 
 
 Thanks, Thomas! That worked, but using din was enough. However, it's 
 still not working with C. What's so different with DMC, Visual C++ and 
 LCC that that doesn't work?
 
Nevermind, I found the problem: I was fflushing after some reads. Thanks again. -- Carlos Santander Bernal
Oct 02 2005