Search code examples
d

Simple D program Output order is wrong


I am learning a new language called "D" but i have a problem when trying to write a simple program

import std.stdio;

void main()
{
    double gradeOne;
    writeln("Please enter the First Test Grade: ");
    readf(" s", &gradeOne);


}

Why does my program ask me for the input first before the output message?

I think its just the DDT problem, when i run the program in command prompt its working fine


Solution

  • Output to Eclipse buffers output by larger data blocks rather than lines. To force output to appear, insert calls to stdout.flush(); before asking for input to ensure it shows up when you want it.

    See also: Eclipse console writes output only after the program has finished