title: Clearing output of a terminal program Linux C/C++
body: <p>I'm interested in clearing the output of a C program produced with printf statements, multiple lines long.</p>
  
  <p>My initial guess was to use </p>
  
  <pre><code> printf("output1\n");
   printf("output2\n");
   rewind(stdout);
   printf("output3\n");
   printf("output4\n");
  </code></pre>
  
  <p>but this produces</p>
  
  <pre><code> output1
   output2
   output3
   output4
  </code></pre>
  
  <p>I was hoping it would produce</p>
  
  <pre><code> output3
   output4
  </code></pre>
  
  <p>Does anyone know how to get the latter result?</p>