title: C++ How do I erase a line from the console?
body: <p>So I have this code that I'm working on and I used a switch statement. What I want to do is when any invalid option is selected, the program should display a message and then after some time clear only the message while keeping the options still on screen.
  In my so far of a code, I used Windows.h library's Sleep function for a pause and also used goto to go back to asking the option but can't seem to figure out how to erase the error message from the screen. I can't use <code>system("cls");</code> because I have a menu before this option selection kind of like a login so I don't want it gone until a valid option has been selected.
  Here's my code:</p>
  
  <pre><code>cout&lt;&lt;endl&lt;&lt;"\t\t\t\t\t\t                            - Access Denied! -"&lt;&lt;endl;
  cout&lt;&lt;"\t\t\t\t\t\t                         + Press [1] To Try Again. +"&lt;&lt;endl;
  cout&lt;&lt;"\t\t\t\t\t\t                         + Press [2] To Go Back. +"&lt;&lt;endl;
  char TryAgain = ' ';
  cout&lt;&lt;"\t\t\t\t\t\t                                 &gt;&gt;[ ]&lt;&lt; ";
  InvalidOption:
  SetConsoleCursorPosition(hStdout, { 84, 14 });
  cin&gt;&gt;TryAgain;
  switch (TryAgain)
  {
      case '1':
          goto LoginAgain;
      case '2':
          break;
      default:
          {
              cout&lt;&lt;"\t\t\t\t\t                            Select A Valid Option!";
              Sleep ( 450 );
              cout &lt;&lt; "\b";
              goto InvalidOption;
          }
  }
  </code></pre>
  
  <p>Yes I'm using tons of <code>/t</code> and maybe a bunch of other stuff but its just a sample code I was trying instead of directly experimenting on my original project.</p>