title: How to delete a character in password masking c++
body: <p>I'm currently making a login form for my project, but I can't move on on this one. I want my program to delete a character(in password) when I'm pressing the backspace button, but the program is not reading it.</p>
  
  <p>Here's my code</p>
  
  <pre><code>string username, password, power;
  char ast=' ';
  int aste = 0, accessLevel;
  ofstream addAcc;
  addAcc.open("Accounts.txt");
  cout&lt;&lt;"Username: ";cin.ignore();getline(cin, username);
  cout&lt;&lt;"Password:  ";
  do
  {
      ast = getch();
  
      if (ast == 13 || ast == ' ' )
      {
          break;
      }
      if(ast==8 || password!="")
      {
          cout&lt;&lt;"\b \b";
          password.erase(password.size()-1);
      }
      cout&lt;&lt;"*";
      password+=ast;
      aste ++;
  }while(ast!=13 || ast!=' ');
  do
  {
      cout&lt;&lt;"Enter Access Level(0-1):  ";cin&gt;&gt;accessLevel;
      switch(accessLevel)
      {
          case 0:
              {
                  power = "Cashier";
                  break;
              }
          case 1:
              {
                  power = "Manager";
                  break;
              }
          default: 
              cout&lt;&lt;"Invalid access level."&lt;&lt;endl;
      }
  }while(accessLevel&gt;1||accessLevel&lt;0);
  </code></pre>
  
  <p>Thank you for those who will help.</p>