title: how to clear my previous output in Linux terminal using C?
body: <p>This is my sample program for simulating a Loading progress. The only problem I'm facing right now is clearing my previous output of "Loading: %i"</p>
  
  <pre><code>/* loading program */
  
  #include &lt;stdio.h&gt;
  #include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define TIMELIMIT 5
  
  int main()
  {
      for(int i = 0, j; i &lt; 5; ++i) {
          j = i;
          printf("Loading: %i%%", ++j);
          sleep(1);
      //system("bash -c clear");    not working
      //printf("\033[2J\033[1;1H"); clears whole screen with no output at all
      }
      return(0);
  }
  </code></pre>