I'm using a piece of code from cplusplus, and i can't get it why this code just skips the input part for password and just jumps right to the input for EMAIL.
//function to mask the input for password
    string getpass(const char *prompt, bool show_asterisk=true)
    {
      const char BACKSPACE=127;
      const char RETURN=10;
      string password;
      unsigned char ch=0;
      //cout <<prompt<<endl;
      while((ch=getch())!=RETURN)
        {
           if(ch==BACKSPACE)
             {
                if(password.length()!=0)
                  {
                     if(show_asterisk)
                     cout <<"\b \b";
                     password.resize(password.length()-1);
                  }
             }
           else
             {
                 password+=ch;
                 if(show_asterisk)
                     cout <<'*';
             }
        }
      cout <<endl;
      return password;
    }  
And here I'm calling this function:
void AgendaUI::userRegister(void)
  {
    string name, password, email, phone;
    //cout << "\n[register] [username] [password] [email] [phone]" << endl;
    cout << "\n[regist]";
    cout << "\n[username] ";
    cin >> name;
    cout << "[password] ";
    password = getpass("Enter the password",true);
    cout << "\n[email] ";
    cin >> email;
    cout << "[phone] ";
    cin >> phone;
}  
 
     
    