my first D program, what is wrong with it?

Gilles G. schaouette at free.fr
Thu Sep 27 15:00:26 PDT 2007


Well, I think on windows \r also clears the current line...
So instead you should use something like:

 import std.stdio;
 
 int main(char[][] args)
 {
 
     writefln("===================");
     for (int i = 0; i < 50000; i++) {
       writef("\rhaaaaa ", i);
     }
     writefln("\n===================");

     return 0;
 }

This should work, but notice that I did not try it...
dominik Wrote:

> ok, I've just unzipped dm and dmd, and I have tried to write my first 
> trivial D program - just to get started (below is the code I wrote). It 
> works, from the first try :) However, it behaves em weird.
> First writefln works like it is supposed to, last one also, however writef 
> should just write in place haaaa and the number (hence the \r). But, when 
> printing in place is done, and the last writefln fires off, line where 
> writef wrote to disappears. How, why?
> 
> I'm on windows XP if that matters
> ----------------------------------------------
> import std.stdio;
> 
> int main(char[][] args)
> {
> 
>     writefln("===================");
>     for (int i = 0; i < 50000; i++) {
>       writef("haaaaa ", i, " \r");
>     }
>     writefln("===================");
> 
>     return 0;
> }
> ---------------------------------------------- 
> 
> 



More information about the Digitalmars-d-learn mailing list