How to read the keyboard when stdin redirected
Darren Drapkin
darren.drapkin at ntlworld.com
Thu May 14 10:11:47 UTC 2026
On Thursday, 14 May 2026 at 09:17:15 UTC, Darren Drapkin wrote:
> On Wednesday, 13 May 2026 at 18:13:06 UTC, Adam D. Ruppe wrote:
>> Open /dev/tty as a file and read from it.
>
> I have tried opening /dev/tty like this:-
>
> auto my_in = File("/dev/tty", "r");
>
> Then I read from it later on like this :-
>
> my_in.readf(" %s",&response);
>
> But the programme, just hangs there waiting for input and doing
> nothing.
I have now tried a new syntax for readf, from a search on readf
my_in.readf!"%s\n"(response);
This seems to work, if I remember to press enter.
More information about the Digitalmars-d-learn
mailing list