title: C remove printf output
body: <p>I would like to create a small function, which should show the current status in percentage in the console. The function should only show the current value in the line.
  So I have to remove the last output. Is that possible? The best case would be some ANSI C stuff, the program should work on linux and windows.</p>
  
  <p>I have found some escape sequences like <code>"\033[J"</code>, but it dose not work.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Well I tried it with:</p>
  
  <pre><code>void PrintProcessBar(int i, int n) {
      float ratio = i / (float)n;    
      printf("%.3d\b\b", (int)(ratio * 100));
      fflush(stdout);
  }
  </code></pre>
  
  <p>But it just print lots of zeros... What went wrong? If I use three <code>\b</code> I get nothing.</p>
  
  <p><strong>Solution</strong></p>
  
  <pre><code>float ratio = (i / (float)n) * 100;
  printf("\b\b\b\b");
  fflush(stdout);
  printf("%.3d%c", (int)ratio, 37);        
  fflush(stdout);
  </code></pre>
  
  <p>i = current position.
  n = max runs.</p>
  
  <p>I use 4 <code>\b</code> because, at the first call of the function it will remove 4 spaces.</p>
  
  <p>Greetz.</p>