Thread overview
redirect input on windows
Oct 02, 2005
Carlos Santander
Oct 02, 2005
Thomas Kühne
Oct 02, 2005
Carlos Santander
Oct 02, 2005
Carlos Santander
October 02, 2005
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
October 02, 2005
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
October 02, 2005
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
October 02, 2005
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