title: Delete the last line outputted into console from a cout?
body: <p>Making a program that has a % progress bar of sorts, its really spammy though. It's creating 100,000 numbers, and showing how far along in the progress it actually is, with a 1% 2% 3% kind of feel, only problem is, it's making the console flood with those numbers, about a thousand of them per percentage increase.</p>
  
  <p>It's probably irrelevant but heres the code I'm using</p>
  
  <pre><code>int testing() {
      cout &lt;&lt; "Open file\n";
      fstream outFile("text.txt", ios::out);
      int number = 100000;
      for (int i = 1; i != number + 1; i++) {
          outFile &lt;&lt; i &lt;&lt; endl;
          cout &lt;&lt; (i / 1000) &lt;&lt; endl;
          //cout &lt;&lt; clearLastLine();
      }
      outFile.close();
      cout &lt;&lt; "File Closed\n";
      return 0;
  }
  </code></pre>
  
  <p>The commented cout is what I want to use (it doesn't exist to my knowledge). Every time the <code>cout &lt;&lt; i/1000 &lt;&lt; endl;</code> triggers, I want it to remove that number it just put into the console window, so it can be replaced with the next number. Is this possible? If it is, I'd love to know - thanks. -- This picture below, shows why I want it to clear the last line that was outputted.
  <a href="https://i.stack.imgur.com/dDYP7.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/dDYP7.jpg" alt="lots of 99% then 100% to close"></a></p>
  
  <p>New code that makes it less spammy, but I still end up with 100 lines of console I do not want, however I still want the newest number to display, just the others not to.</p>
  
  <pre><code>int testing() {
      cout &lt;&lt; "Open file\n";
      fstream outFile("text.txt", ios::out);
      int number = 100000;
      int percentifier = number * .01; // added this so I can change number to be anything I want
      int temp2 = 0;
      for (int i = 1; i != number + 1; i++) {
          outFile &lt;&lt; i &lt;&lt; endl;
          int temp = i / percentifier;
          if (temp != temp2) {
              //cout &lt;&lt; clearLastLine();
              cout &lt;&lt; (temp) &lt;&lt; "%" &lt;&lt; endl;
          }
          temp2 = i / percentifier;
      }
      outFile.close();
      cout &lt;&lt; "File Closed\n";
      return 0;
  }
  </code></pre>