# Reading a single character from `stdin`

```c
int getchar(void);
```
Reads only a single character.

:::{literalinclude} ../code-wi/reading_a_single_character.c
:language: c
:::
:::{command-output} echo geko | code-wi/reading_a_single_character.exe
:shell:
:::

:::{card} 🤔 Question to ponder
Why does our program not do something before we use <kbd>Enter</kbd>?
<!--consoles use line-buffering as default-->
:::

:::{activity} Character counter
Write a program that after each character input shows a counter of total number of space characters. It only reads one character and must discard others. `e` exits your program.

Use `isspace(int ch)` from `ctype.h` that outputs `true` if a character is a space character.

```text
Enter a character: 3
Total: 0
Enter a character: 
Total: 1
Enter a character: leverpostej
Total: 1
Enter a character: e
```
:::