How do I read one character from stdin? (getc in C)

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 14 05:56:49 PST 2015


On Saturday, 14 November 2015 at 13:33:49 UTC, Fer22f wrote:
> Hello! I'm starting to make some simple command line programs 
> and one thing I miss from C is a function for getting one 
> character from the input. This is for example, an "Press Any 
> Key Program".
>
> Anyone that has more experience can point me into a solution 
> that is not deprecated? I haven't even researched about the 
> deprecated options but looked into all free available D books I 
> could find and I only found ways to get entire lines (even if 
> it's just one character I still need to press enter).

Well you can always call C in d i.e.

import core.stdc.stdio;

void main(string[] args)
{
     char c = getc();
}



More information about the Digitalmars-d-learn mailing list