简体   繁体   English

Ncurses无输出

[英]Ncurses No Output

  • Platform: Linux 3.2.0 x86 (Debian Wheezy) 平台:Linux 3.2.0 x86(Debian Wheezy)
  • Compiler: GCC 4.7.2 (Debian 4.7.2-5) 编译器:GCC 4.7.2(Debian 4.7.2-5)

I am writing a program that requires advanced terminal control that is provided by ncurses but I cannot get my program to print anything to stdscr. 我正在编写一个程序,该程序需要ncurses提供的高级终端控制,但无法使我的程序将任何内容打印到stdscr。 For example if I compiled the following code I would not see "Testing.. Testing" on the screen. 例如,如果我编译以下代码,则在屏幕上不会看到“ Testing .. Testing”。 I have used ncurses before and I have never encountered such a problem. 我以前使用过ncurses,但从未遇到过这样的问题。 I do not know if this is relevant or not but I am running a fresh install of Debian (I literally installed it a couple of hours ago). 我不知道这是否相关,但是我正在运行Debian的全新安装(我几个小时前就安装了它)。

#include <ncurses.h>

int main()
{
    initscr();
    printw("Testing... Testing");
    refresh();
    return;
}

Also the above progam was compiled with, 上面的程序也是这样编译的:

gcc --all-warnings --extra-warnings -std=c11 filename.c -lncurses

If you want to see the text, maybe you should keep the program running when you're printing it. 如果要查看文本,也许在打印程序时应保持程序运行。

#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;
}

You can get more informations on the ncurses "hello world": http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html 您可以在ncurses“ hello world”上获取更多信息: http : //tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM