I seem to be able to crash writefln

Steven Schveighoffer schveiguy at yahoo.com
Thu Mar 10 04:18:52 PST 2011


On Wed, 09 Mar 2011 18:19:55 -0500, Joel Christensen <joelcnz at gmail.com>  
wrote:

> This is on Windows 7. Using a def file to stop the terminal window  
> coming up.
>
> win.def
> EXETYPE NT
> SUBSYSTEM WINDOWS
>
> bug.d
> import std.stdio;
> import std.string;
>
> void main() {
> 	auto f = File( "z.txt", "w" );
> 	scope( exit )
> 		f.close;
> 	string foo = "bar";
> 	foreach( n; 0 .. 10 ) {
> 		writefln( "%s", foo );
> 		f.write( format( "count duck-u-lar: %s\n", n ) );
> 	}
> }
>
> output (from in z.txt):
> count duck-u-lar: 0

If I dust off my rusty old Windows hat, I believe if you try to write to  
stdout while there is no console window, you will encounter an error.

So don't do that ;)  I'm not sure what you were expecting...

-Steve


More information about the Digitalmars-d-learn mailing list