C code - get key press - no echo - a to z and 0 to 9

I need to wait for a key, ‘n’, then continue. No echo of character. You don’t have to press enter.

#read -n 1 -s -r

This works in bash. If I try using the ‘system’ function, I get a keyboard freeze, but no key will continue.


system(“read -n 1 -s -r”);

How to make this work? Else, some other way to wait for a keypress in C.


Have you tried using the console I/O function? i.e. getch()

If you mean ncurses-devel, yes. It gives this error.

#include <curses.h>
//int getch(void);


/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: /tmp/ccMMPcLf.o: in function `Scan_Results_Filter':
scanvirus.c:(.text+0x538): undefined reference to `_nc_stdscr'
/usr/lib64/gcc/x86_64-suse-linux/7/../../../../x86_64-suse-linux/bin/ld: scanvirus.c:(.text+0x540): undefined reference to `wgetch'
collect2: error: ld returned 1 exit status

I need to have the screen unaltered to trace the program logic.

I got it working by adding “gcc -g scanvirus.c -o scanvirusbin -lncurses”

It doesn’t work. I can’t get getkey to work. Any method using ncurses, clears the screen. This will not work either for my code.

Still need help…