- 平台:Linux 3.2.0 x86 (Debian Wheezy)
- 编译器:GCC 4.7.2 (Debian 4.7.2-5)
我正在编写一个需要 ncurses 提供的高级终端控制的程序,但我无法让我的程序将任何内容打印到 stdscr。例如,如果我编译了以下代码,我将不会在屏幕上看到“Testing.. Testing”。之前用过ncurses,没遇到过这样的问题。我不知道这是否相关,但我正在运行全新安装的 Debian(我实际上是几个小时前安装的)。
#include <ncurses.h>
int main()
{
initscr();
printw("Testing... Testing");
refresh();
return;
}
上面的程序也是编译的,
gcc --all-warnings --extra-warnings -std=c11 filename.c -lncurses
最佳答案
如果你想看到文本,也许你应该在打印时让程序保持运行。
#include <ncurses.h>
int main()
{
initscr();
printw("Testing... Testing");
refresh();
getch(); // Wait the user input in order to keep the program active and showing text.
endwin(); // Terminate the window to clean all memory allocations.
return;
}
您可以获得有关 ncurses“hello world”的更多信息:http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html
关于c - Ncurses 无输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22135225/