www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - continued: Bug or what?

reply Tomás Rossi <Tomás_member pathlink.com> writes:
Also, writefln or writef("\n") doesn't seems to suffer from this.
Setting a writefln("") just before the pause call fixes all.
Maybe it has something to do with the newline. Neglecting to flush until a
newline?


Tom
Nov 13 2005
parent reply "Regan Heath" <regan netwin.co.nz> writes:
On Mon, 14 Nov 2005 03:09:30 +0000 (UTC), Tomás Rossi  
<Tomás_member pathlink.com> wrote:
 Also, writefln or writef("\n") doesn't seems to suffer from this.
 Setting a writefln("") just before the pause call fixes all.
 Maybe it has something to do with the newline. Neglecting to flush until  
 a newline?
I suspect the buffer flushes on a newline, so the writef goes into the buffer but isn't flushed, then, I suspect the pause text doesn't go into the buffer but straight to the console. So it gets there before the buffered text. Regan
Nov 13 2005
parent Dave <Dave_member pathlink.com> writes:
In article <opsz7n250r23k2f5 nrage.netwin.co.nz>, Regan Heath says...
On Mon, 14 Nov 2005 03:09:30 +0000 (UTC), Tomás Rossi  
<Tomás_member pathlink.com> wrote:
 Also, writefln or writef("\n") doesn't seems to suffer from this.
 Setting a writefln("") just before the pause call fixes all.
 Maybe it has something to do with the newline. Neglecting to flush until  
 a newline?
I suspect the buffer flushes on a newline, so the writef goes into the buffer but isn't flushed, then, I suspect the pause text doesn't go into the buffer but straight to the console. So it gets there before the buffered text. Regan
The 'terminal' IO library routines underlying phobos will flush on a newline or close by default for both Windows and Linux. So it isn't strictly a bug unless it's defined otherwise. This default behaviour can be changed by using std.c.stdio.setvbuf(...);
Nov 13 2005