Thread overview | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
November 14, 2005 Bug or just ugly behavior? | ||||
---|---|---|---|---|
| ||||
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 |
November 14, 2005 Re: Bug or just ugly behavior? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tomás Rossi | 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
|
November 14, 2005 Re: Bug or just ugly behavior? (ok thx) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | 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 |
November 15, 2005 Re: Bug or just ugly behavior? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Unknown W. Brackets | 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. -- -----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. |
November 18, 2005 Re: Bug or just ugly behavior? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | *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.
>
|
Copyright © 1999-2021 by the D Language Foundation