Using getchar
Jesse Phillips
jessekphillips+D at gmail.com
Fri Sep 10 07:24:58 PDT 2010
On Thu, 09 Sep 2010 21:44:43 -0400, Andrej Mitrovic wrote:
> Jesse Phillips Wrote:
>
>> Hello,
>>
>> I didn't get much feedback on what was thought about it. I think I'll
>> try the Phobos mailing list...
>
> Okay, give it a try. :)
>
>> without my library the code would look something like (sorry cant test
>> right now)
>>
>> import std.stdio;
>>
>> void main()
>> {
>> char k;
>>
>> for(int i = 0; i < 10; i++)
>> {
>> writef("Press key #%d:\t\n", i);
>> k = std.conv.to!char(readln());
>> }
>> }
>
> Something like that, but not using readln() since it returns an array of
> chars and we need a single char.
I hadn't posted the code yet because it wasn't really general enough. But
the example I gave, because readln() should return "a\n" and to!char
(...), should convert that into a char just as you want.
More information about the Digitalmars-d-learn
mailing list