writef

Steven Schveighoffer schveiguy at yahoo.com
Tue Jan 13 10:49:20 PST 2009


"Claus D. Volko" wrote
> Adam D. Ruppe Wrote:
>
>> On Sun, Jan 11, 2009 at 10:15:45AM -0500, Claus D. Volko wrote:
>> > Thanks for your answer. It sounds plausible to me. Do you know how to 
>> > manually cause a flush? I've found this code snippet:
>>
>> fflush(stdout);
>>
>> That should do it and is imported in std.stdio;
>
> I've tried it - it doesn't help. :(
>
> // The "Hello World!" program
>
> import std.stdio;
> import std.c.stdio;
>
> void main ()
> {
>  int i;                                    // Variable definition
>  i = 200;                                  // Assignment
>  writefln ("Hello World!");                // Function call
>  writef ("The value of i is ", i, ".");    // Function call
>  getch ();                                 // Function call
>  fflush (stdout);

Try reversing the two above lines:
fflush(stdout);
getch();

What you are doing is waiting for the input and then flushing stdout --  
exactly the same as what you had originally.

> }
>
> I've also tried calling std.stdio.fflush (stdout); to avoid calling the 
> function from std.c.stdio - not the desired effect either.
> 





More information about the Digitalmars-d mailing list