2014-04-11 122 views
-1

我想在C++中使用ncurses進行進度條,但是我還沒有成功。所有'#'同時出現,沒有動畫。有人能幫助我嗎。進度條ncurses

這是我的代碼:

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

謝謝您的幫助。

回答

3

你可能應該在mvaddch(0,n,'#');之後加refresh();。否則,屏幕會在您的示例中的循環結尾處立即出現。

+1

your'e the man :) – fchaouqui