-2

在 termux (Android Linux terminal emulator) 上遇到了这个问题。这是整个代码:

#include <ncurses.h>    
int main() {
    initscr();
    getch();
    endwin();
}

然后我使用这一行编译:

g++ -lncurses prog.cpp

该软件包是 ncurses-dev 6.1.20180331(最新版本)PS,即使refresh()它不起作用。

4

1 回答 1

0

如果 initscr 返回 null ,则程序必须结束。

如果 initscr 返回 null,则在程序中执行进一步的代码是不安全的

WINDOW * mainwin;

if ( (mainwin = initscr()) == NULL ) {
    /* Error handling here */
    exit(EXIT_FAILURE);
}

参考:

http://www.paulgriffiths.net/program/c/srcs/curin1src.html

于 2018-04-15T18:38:44.657 回答