title: Printing on same line in c++
body: <p>I am trying to write the time on the same line instead of it stacking the outputs. I can not seem to get it to work though. </p>
  
  <p>Here is what I have: I thought the <code>"\r"</code> would make it reprint on the same line, but this doesn't work. And I also tried <code>printf("\r");</code> and that didn't work either.</p>
  
  <p>Can anyone help me figure out how to get this to work?</p>
  
  <pre><code>void countdown(int time)
  {
      int h = (time / 3600);
      int m = (time / 60) - (h * 60);
      int s = time % 60;
  
      std::stringstream ss;
      ss &lt;&lt; h &lt;&lt; ":" &lt;&lt; m &lt;&lt; ":" &lt;&lt; s;
      std::string string = ss.str();
  
      cout &lt;&lt; "\r" &lt;&lt; string &lt;&lt; endl;
  }
  </code></pre>