On Saturday, 26 December 2015 at 19:52:15 UTC, Adam D. Ruppe
wrote:
On Saturday, 26 December 2015 at 19:40:59 UTC, Jay Norwood
wrote:
Simple VS console app in D.
If you are running inside visual studio, you need to be aware
that output will be block buffered, not line buffered, because
VS pipes the output making the program think it is talking to
another program instead of to an interactive console (well,
because it is!)
Add a stdout.flush(); after writing to force it to show
immediately. I really think the read functions ought to flush
output too because this is such a FAQ. (indeed, my terminal.d
does flush output when you request input)
I experience the same as the OP on Linux Mint 15 with dmd2.069
and 64 bit machine. I have to press enter twice to get the
output. I read http://ddili.org/ders/d.en/input.html and inserted
a space before %s but still no use. Am I missing something here
with the latest version?
Code
import std.stdio;
int main(string[] argv)
{
string nm;
readf(" %s\n",&nm);
writeln("nm:",nm);
// readf(" %s\n",&nm);
// writeln("nm:",nm);
return 0;
}
Output
56
2
nm:56