www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Bug or just ugly behavior?

reply Tomás Rossi <Tomás_member pathlink.com> writes:
Code:

# private import std.stdio, std.process;
# 
# void main()
# {
#   writefln("Some text");
#   writef("Another text");
#   std.process.system("pause");
# }

Compiled with dmd 0.139 win32, executed it outputs:

Some text
Press any key to continue . . .
Another text

It's a buffered output normal behavior or something wrong with pause call?
Do you guys think this is a bug?

Tom
Nov 13 2005
parent reply "Unknown W. Brackets" <unknown simplemachines.org> writes:
I'm pretty sure, even with cout and friends in C++, you have to flush 
the stream before you want to run a system call like that.

On a tangent, that's horribly inefficient.  I'm sure there is (or should 
be) a function to wait for input, and if there is not, piping it ain't 
the way, is it?

Anyway, try adding a fflush in there before the pause, e.g.:

fflush(stdio);

-[Unknown]


 Code:
 
 # private import std.stdio, std.process;
 # 
 # void main()
 # {
 #   writefln("Some text");
 #   writef("Another text");
 #   std.process.system("pause");
 # }
 
 Compiled with dmd 0.139 win32, executed it outputs:
 
 Some text
 Press any key to continue . . .
 Another text
 
 It's a buffered output normal behavior or something wrong with pause call?
 Do you guys think this is a bug?
 
 Tom

Nov 13 2005
next sibling parent Tomás Rossi <Tomás_member pathlink.com> writes:
In article <dl98hd$2rf$1 digitaldaemon.com>, Unknown W. Brackets says...
I'm pretty sure, even with cout and friends in C++, you have to flush 
the stream before you want to run a system call like that.

On a tangent, that's horribly inefficient.  I'm sure there is (or should 
be) a function to wait for input, and if there is not, piping it ain't 
the way, is it?

Anyway, try adding a fflush in there before the pause, e.g.:

fflush(stdio);

-[Unknown]

Ok, I suspect this was the case. Though I think I've done this with C (don't know if printf in C behave like this) and C++ and despite of buffers I could never note such an excesive buffering result. I'll keep moving, Thanks.
 Code:
 
 # private import std.stdio, std.process;
 # 
 # void main()
 # {
 #   writefln("Some text");
 #   writef("Another text");
 #   std.process.system("pause");
 # }
 
 Compiled with dmd 0.139 win32, executed it outputs:
 
 Some text
 Press any key to continue . . .
 Another text
 
 It's a buffered output normal behavior or something wrong with pause call?
 Do you guys think this is a bug?


Tom
Nov 14 2005
prev sibling parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Unknown W. Brackets wrote:
 I'm pretty sure, even with cout and friends in C++, you have to flush 
 the stream before you want to run a system call like that.
 
 On a tangent, that's horribly inefficient.  I'm sure there is (or should 
 be) a function to wait for input,

std.c.stdio.getch() Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++ a->--- UB P+ L E W++ N+++ o K- w++ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit.
Nov 15 2005
parent "Unknown W. Brackets" <unknown simplemachines.org> writes:
*smacks his head*...

Yes, yes, that's the one.  I've not done enough console programming of 
late :$.

-[Unknown]


 Unknown W. Brackets wrote:
 
 I'm pretty sure, even with cout and friends in C++, you have to flush 
 the stream before you want to run a system call like that.

 On a tangent, that's horribly inefficient.  I'm sure there is (or 
 should be) a function to wait for input,

<snip> std.c.stdio.getch() Stewart.

Nov 17 2005