title: How can I make a second cout without destroying my first in this program?
body: <pre><code>#include "stdafx.h"
  #include "iostream"
  #include "thread"
  #include "conio.h"
  #include "windows.h"
  using namespace std;
  
  void incrm();
  void charget();
  
  void main() {
      thread count(incrm);
      thread getcin(charget);
  
      count.join();
      getcin.join();
  
      cin.get();
  }
  
  void incrm() {
      int j = 0;    // used to increment and output
      while (true) {
          cout &lt;&lt; "\r" &lt;&lt; j;    // outputs 1,2,3,4... and so on
          j++;
          Sleep(150);
      }
      cout &lt;&lt; endl;
  }
  
  void charget() {
      while (true) {
          int i = getch();    // gets value of char
          cout &lt;&lt; "\r\nCHAR: " &lt;&lt; i;  // and here is the problem...!
      }
  }
  </code></pre>
  
  <p>So I wanted this program to output a number in the first line, which increments without stopping and if you hit any key it should cout the value of that key in a secound line, so i wanted it to output something like this-></p>
  
  <pre><code>45
  CHAR: 97
  </code></pre>
  
  <p>and after you have hit a key the incrementing number should stay in the first line. If you hit several keys the second cout should be overwritten, but this doesnt seem to work for me, my output looks like this if i hit several keys-></p>
  
  <pre><code>10
  12AR: 97
  20AR: 96
  </code></pre>
  
  <p>My problem is that my first cout (the incrementing number) overwrites my second (or my second my first I don't really know) and then this countinues for every line! :(</p>