stdin/stdout and flush

a11e99z black80 at bk.ru
Tue Aug 27 20:45:44 UTC 2019


On Tuesday, 27 August 2019 at 20:09:34 UTC, Andre Pany wrote:
> 
> This applications will be called by a second application:
> import std;
> void main() {
>     auto p = pipeShell("a", Redirect.all);
>     p.stdin.writeln("e1");
>     p.stdin.writeln("10");
>     p.stdin.writeln("e2");
>     p.stdin.writeln("9");
>     p.stdin.flush();
>     p.stdout.readln();
> }
>
> In application a.d the first "while round" will succeed as 
> expected. But in the second "while round" the readln does not 
> wait until there is an input but gets an empty string. The 
> to!int will therefore throw an exception.
>
> Why does the readln returns an empty string in the second run 
> and does not wait on an input?
>

probably cuz no second "send round" in b.d.
or u mean second half-round "e2,9"?


More information about the Digitalmars-d-learn mailing list