C exit from infinite loop on keypress

c, getch, infinite-loop

Solution

If you are using `getch()` from `conio.h` anyway, try to use `kbhit()` instead. Note that both `getch()` and `kbhit()` - `conio.h`, in fact - are not standard C.

Problem

How can I exit from an infinite loop, when a key is pressed? Currently I'm using getch, but it will start blocking my loop as soon, as there is no more input to read.

Original source