In C++, how can a percentage progress bar be placed at the bottom of a Linux terminal while general printouts are displayed (not overwritten) also? -


i have program loops on files, doing various things them. each file, program prints output terminal. output of various forms (over have no control).

i want have percentage progress bar displayed solely @ bottom of terminal output, below of continuous output of file processing activities. how this?

note not have access ncurses.

using guidance a previous question, have basic attempt here:

#include <unistd.h> #include <iostream> #include <string>  using namespace std;  void print_progress_bar(int percentage){   string progress = "[" + string(percentage, '*') + string(100 - percentage, ' ') + "]";   cout << progress << "\r\033[f\033[f\033[f" << flush; }  void print_stuff(){     int number_of_lines = (rand() % 9) + 1;     (int i=0; <= number_of_lines; ++i){         cout << "some junk output of " << number_of_lines << " lines\n";     } }  int main(){   cout << endl;   (int i=0; <= 100; ++i){     std::cout << "processing file number " << << "\n";     print_stuff();     print_progress_bar(i);     usleep(10000);   }   cout << endl;   cout << endl;   cout << endl;   cout << endl; } 


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -