title: C++: Is it possible to erase what was already printed on the terminal?
body: <p>I'm working on a text adventure game:</p>
  
  <pre><code>#include &lt;string&gt;
  #include &lt;cstdio&gt;
  
  
  using namespace std;
  
  int main (){
  cout &lt;&lt; "Welcome to text adventure! Do you want to play? (y/n)\n";
  
  char ansr;
  cin &gt;&gt; ansr;
  
  while (ansr == 'y' || 'Y'){
      cout &lt;&lt; string (50, '\b');
      cout &lt;&lt; "Okay, let's go!";
      return 0;
  }
  }
  </code></pre>
  
  <p>This works alright, but for readability I want the new text "okay, let's go!" to appear at the top of the screen. This is part of an educational assignment, but i really like my idea for my text adventure game. <code>system(CLS);</code> Does the job but i've been reading that there are some major portability issues with this since it can only work with windows.</p>
  
  <p>I've tried resplacing <code>\n</code> with <code>\b</code> and it doesn't do anything because <code>\b</code> is only meant to erase what the console is typing. I'm wondering if there's a way the earlier things that were printed on the console. If not, are there any other alternatives to <code>system(CLS)</code> other than what I have on there to allow the new text to be bumped up to the top of the screen?</p>