Reading console input on OSX

I use scanf()to read user input on a terminal in a console application. scanf waits until the user runs the return key for reading. Is there a way to read user input every time I press a key?

+5
source share
3 answers

The usual way would be to use a function getchfrom (Mac port) ncurses .

Note that while getcharreading a single character, it still usually performs buffering, so you need to press return / enter before it returns.

+6

getch() stdin .

+2
char c = getchar();

He has to do the trick.

+1
source

All Articles