my first D program, what is wrong with it?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Thu Sep 27 15:26:35 PDT 2007


BCS wrote:
> Reply to Frits,
> 
>> BCS wrote:
>>
>>> Reply to dominik,
>>>
>>>> ----------------------------------------------
>>>> import std.stdio;
>>>> int main(char[][] args)
>>>> {
>>>> writefln("===================");
>>>> for (int i = 0; i < 50000; i++) {
>>>> writef("haaaaa ", i, " \r");
>>>> }
>>>> writefln("===================");
>>>> return 0;
>>>> }
>>>> ----------------------------------------------
>>> IIRC writefln starte outputting at the current location and appens a
>>> newline at the end. It does not ever add a newline at the start.
>>
>> The middle one is writef, not writefln.
>> And I think the point of this program is not to put newlines between
>> the
>> outputs, but to keep overwriting the last line (as a progress
>> indicator,
>> I guess). Which is exactly what it does on Linux by the way, with both
>> DMD and GDC.
> 
> that is how I was reading it. The error I think is in question is that 
> the writfln replaces the last line from the writef.

Oh wait, I must've misread the original post. Yes, that's what happens 
(I just didn't realize that was the problem -- I thought he didn't see 
the counting at all)
dominik: Try adding a writefln() right after the loop, or prepending 
"\n" to the last string.


More information about the Digitalmars-d-learn mailing list