Did somebody change the automatic stdout.flush behavior?
Ali Çehreli
acehreli at yahoo.com
Thu Feb 17 08:06:45 UTC 2022
On 2/16/22 23:19, Paulo Pinto wrote:
> I bet you are mixing it up with connecting FILE streams to iostreams.
>
> https://en.cppreference.com/w/cpp/io/ios_base/sync_with_stdio
Thank you. That must be it.
Regardless whether the automatic flush is standard or not, it is indeed
the case at least in a terminal. When I run the following program
without version=input (as commented out below), I see the output in
waves of 1024 characters. (The first wave appears after about 3 seconds.)
However, when I run it with version=input, I see that the output is
automatically flushed before the input:
import std.stdio;
import core.thread;
// version = input;
enum inputPeriod = 10;
void main() {
foreach (i; 1 .. 10_000) {
Thread.sleep(10.msecs);
write(' ', i);
version (input) {
if (i % inputPeriod == 0) {
write("Enter a char: ");
char c;
readf(" %s", &c);
}
}
}
}
It's perhaps the terminal, which me likes. No big deal...
Ali
More information about the Digitalmars-d
mailing list