使用 getch() ncurses 时不要打印 char

Don't print char when using getch() ncurses

我需要使用 ncurses 获取一个字符,但是当我获取该字符时,我不想将它打印到屏幕上。有没有办法做到这一点?

假设您使用 C,您可以使用 noecho();

以下是手册页的相关摘录。

The echo and noecho routines control whether characters typed by the user are echoed by getch as they are typed. Echoing by the tty driver is always disabled, but initially getch is in echo mode, so characters typed are echoed. Authors of most interactive programs prefer to do their own echoing in a controlled area of the screen, or not to echo at all, so they disable echoing by calling noecho.