title: Clear stdout in C?
body: <p>Is there any way to clear the standard output buffer in C?</p>
  
  <p>I have a program in which I don't know if I am going to output data until the end of a loop.</p>
  
  <p>I would like to have my logic be something like:</p>
  
  <pre><code>printf("data1\n");
  printf("data2\n");
  
  ...
  
  if (printTuple)
      fflush(stdout); //Print the data to stdout
  else
      /*Clear stdout*/ //Clear stdout
  </code></pre>
  
  <p>I have tried <code>memset(stdout, 0, sizeof(stdout))</code> and <code>rewind(stdout)</code>, neither of which work.</p>