我正在使用CodeBlocks,并且刚刚开始使用PDCurses。我只是在尝试一些东西,然后我遇到了这个问题。
#include <iostream>
#include <curses.h>
using namespace std;
int main()
{
int ch;
initscr();
cbreak();
keypad(stdscr, TRUE);
noecho();
ch = getch();
printw("The key pressed is %d\n", ch);
refresh();
return 0;
}getch()不起作用。它不会等待输入,它会直接打印出来。它只输出“按下的键是-1”。
发布于 2014-07-24 12:51:24
尽管它应该已经是默认行为,但您可以尝试通过nodelay(stdscr, FALSE)显式设置延迟模式。
https://stackoverflow.com/questions/18654329
复制相似问题