进度条 [英] Progression bar ncurses
本文介绍了进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 ncurses 在 C++ 中创建一个进度条,但我还没有成功.所有的#"同时出现,没有动画.有人可以帮我吗.
I'm trying to do a progression bar in c++ using ncurses, but I didn’t succeed yet. All the '#' appears at the same time, there is no animation. Can some one help me please.
这是我的代码:
#include <iostream>
#include <ncurses.h>
#include <unistd.h>
using namespace std;
int main()
{
initscr();
for (int n = 0; n < 10; n++)
{
mvaddch(0,n,'#');
usleep(10000);
}
getch();
endwin();
}
感谢您的帮助.
推荐答案
你可能应该在 mvaddch(0,n,'#'); 之后添加
>.否则,在您的示例中,屏幕会在循环结束时立即出现..refresh();
You probably should add refresh();
after mvaddch(0,n,'#');
. Otherwise the screen appears all at once at the end of the loop in your example..
这篇关于进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文