How to read a single character in D language?

forkit forkit at gmail.com
Wed Nov 24 08:40:16 UTC 2021


On Friday, 19 November 2021 at 17:36:55 UTC, BoQsc wrote:
> Let's say I want to write a simple program that asks for an 
> input of a single character.
> After pressing a single key on a keyboard, the character is 
> printed out and the program  should stop.

module test;

void main()
{
     import core.stdc.stdio : getchar, puts, putchar;
     puts("Enter a character:");
     putchar(getchar());
}



More information about the Digitalmars-d-learn mailing list