Created
          June 28, 2015 21:21 
        
      - 
      
- 
        Save ryankurte/bc3a47e43cbddd2323f5 to your computer and use it in GitHub Desktop. 
    C Command Line Progress Bar
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | void print_progress(unsigned int bar_size, float progress) | |
| { | |
| printf("["); | |
| int8_t pos = bar_size * progress; | |
| for (int i = 0; i < bar_size; ++i) { | |
| if (i < pos) { | |
| PRINTF("="); | |
| } else if (i == pos) { | |
| PRINTF(">"); | |
| } else { | |
| PRINTF(" "); | |
| } | |
| } | |
| printf("] %d %%\r", (int)(progress * 100)); | |
| fflush(stdout); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment