Ncurses无输出 [英] Ncurses No Output

查看:90
本文介绍了Ncurses无输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我正在编写一个程序,该程序需要ncurses提供的高级终端控制,但是我无法让我的程序将任何内容打印到stdscr.例如,如果我编译以下代码,则在屏幕上不会看到"Testing .. Testing".我以前使用过ncurses,但从未遇到过这样的问题.我不知道这是否有意义,但是我正在运行Debian的全新安装(我几个小时前就安装了它).

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. For example if I compiled the following code I would not see "Testing.. Testing" on the screen. I have used ncurses before and I have never encountered such a problem. 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).

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

您可以获取有关ncurses"hello world"的更多信息: http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

You can get more informations on the ncurses "hello world": http://tldp.org/HOWTO/NCURSES-Programming-HOWTO/helloworld.html

这篇关于Ncurses无输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆