Ncurses没有输出

Joh*_*inz 2 c ncurses

  • 平台: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;
}
Run Code Online (Sandbox Code Playgroud)

上面的程序也编译了,

gcc --all-warnings --extra-warnings -std=c11 filename.c -lncurses
Run Code Online (Sandbox Code Playgroud)

Kok*_*iwi 6

如果您想查看文本,也许您应该在打印时保持程序运行.

#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;
}
Run Code Online (Sandbox Code Playgroud)

你可以在ncurses"hello world"上获得更多信息:http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html