title: print to screen from c console application overwriting current line
body: <p>I want to overwrite the current line in a c console program to achieve output like in the linux shell command "top". If possible the method should work under windows and linux.</p>
  
  <pre><code>while (i &lt; 100) {
         i++;
         sprintf(cTmp, "%3d", i);
         puts(cTmp);
         if ((character = mygetch()) == 'q') {
            break;
         }
      }
  </code></pre>
  
  <p>I would like to overwrite the previous number in each iteration and if possible look if the user entered a character without pausing the loop. If the user presses the key 'q' the loop should stop immediately.</p>