title: Loading bar in c without mess up other outputs
body: <p>I need to make a loading bar like the one in the apt packet manager (image)</p>
  <p><a href="https://i.stack.imgur.com/aMczK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aMczK.png" alt="enter image description here" /></a></p>
  <p>I found a <a href="https://github.com/doches/progressbar" rel="nofollow noreferrer">cool library</a> that implements this, the problem though is that since the progress bar is printed, all text above the loading bar (for example in the image, &quot;Processing triggers for...&quot;) is not printed out.</p>
  <p>How can I have both the loading bar and the information printed on the screen?</p>
  <p>my actual code is this:</p>
  <pre><code>int main(void){
    while ((read = getline(&amp;line, &amp;len, file)) != -1) {
    char *newline = strchr(line, '\n');
    if (newline)
      *newline = 0;
    puts(&quot;&quot;);
    currline++;
    progressBar(currline, lines);
   }
  }
  
  void progressBar(size_t count, size_t lines){
    progressbar *progress = progressbar_new(&quot;Loading&quot;,lines); // function provided b the linked library (It initialize the progress bar so takes the name and the number of lines)
    for (size_t i = 0; i &lt; lines; i++)
      progressbar_inc(progress); // provided by the library (it increments progressbar of a single step and call progressbar_update() that print the value by calling progressbar_draw()
    progressbar_finish(progress); // just free all allocated memory and print a newline
  }
  </code></pre>
  <p>If you want to have a more detailed look to cited functions see <a href="https://gist.github.com/HeroS3c/c323cb344ff136219a2292ecc3eee18a" rel="nofollow noreferrer">here.</a></p>