我正在使用 XUBUNTU 16.04 和 Geany。 我开始测试库 ncurses。但我无法显示字符。当我运行程序时出现一个窗口,但字符“a”和“*”没有出现。
这是我的代码:
#include <ncurses.h>
void line(char ch, int n)
{
int i;
for( i = 1; i<=n; i++ )
addch(ch);
}
int main()
{
clear();
line("a", 50);
line("*", 8);
return 0;
}
最佳答案
man curs_refresh
:
The
refresh
andwrefresh
routines (orwnoutrefresh
anddoupdate
) must be called to get actual output to the terminal, as other routines merely manipulate data structures.
因此您的程序缺少 refresh();
。
看起来您还缺少初始化/清理,即在程序开始时调用 initscr()
并在程序结束时调用 endwin()
。
关于c - 使用 ncurses 打印字符失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47499400/