How to read a single character in D language?

Alexey animuspexus at protonmail.com
Wed Nov 24 04:48:46 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.

```D
import std.stdio;

void main()
{
	while (true)
	{
		char c;
		scanf("%c", &c);
		
		writefln(0x"%c (%1$x %1$d) is inputed", c);
	}
}
```


More information about the Digitalmars-d-learn mailing list