How to display a progress indicator in pure C/C++ (cout/printf)?

后端 未结 8 1371
夕颜
夕颜 2020-12-12 11:10

I\'m writing a console program in C++ to download a large file. I have known the file size, and I start a work thread to download. I want to show a progress indicator to mak

8条回答
  •  抹茶落季
    2020-12-12 11:24

    Here is a simple one I made:

    #include 
    #include 
    
    using namespace std;
    
    int barl = 20;
    
    int main() {
       system("color 0e");  
       cout << "[";     
       for (int i = 0; i < barl; i++) {         
          Sleep(100);       
          cout << ":";  
       }
       cout << "]";
    }
    

提交回复
热议问题