'How can I add backspace?

My professor is asking me to make a program that asks for email and password that while the user is typing its password the characters will be changed into *, My problem is whenever I press backspace it continues to print * and not deleting it. Please help me how this program will delete the previous character and not add * when I press backspace. Thanks You can also add a tip on how I can improve my programming

CODE

Here is the code that I'm working with

#include <iostream>
#include <string>
#include <conio.h>
using namespace std;

int main() 
{
    string pass = "";
    char password;
    string email;
    string name;
    name = "Mon Alvin Rafael";
    cout << " Enter Email: ";
    cin >> em;
    cout << " Enter Password: \b";
    password = _getch();
    while (ch != 13) {
        //character 13 is enter
        pass.push_back(password);
        cout << '*';
        ch = _getch();
    }
    if (pass == "password1234" && email == "email1234")
    {
        cout << "\n Welcome " << name << endl;
        return main();
    }
    else 
    {
        cout << "\n Invalid Password or Email" << endl;
        return main();
    }
}
c++


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source