How do I read one character from stdin? (getc in C)
BBaz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Nov 14 05:53:48 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).
---
import std.stdio;
void main(string[] args)
{
char c;
stdin.readf("%c", &c);
writeln(c);
}
More information about the Digitalmars-d-learn
mailing list