Error when user backspace it adds up as a * in the password input

I made a part of the program like below the only problem is that when i click backspace to input password it adds a * instead of deleting one and also when the password is incorrect it gives u another chance but it starts with a * which means if i entered the password wrong it grants me to try again but instead of a blank space it starts with *


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  bool Pass()//This Function's purpose is to not allow any person to park in the faculty reserved area, but only those who have the password needed.
{
	int counter = 0;
	string pass = "";
	char ch;
	cout << "Please enter the password to access the faculty area\n";
	ch = _getch();
	do {
		while ( ch!=13) {//character 13 is enter
			pass.push_back(ch);
			cout << '*';
			ch = _getch();
		}
		if (pass == "123") {
			cout << "\nAccess granted \n";
			return true;
		}
		else {
			cout << "\nAccess Aborted. " << 3 - counter << " Attempts Left\n";
			counter++;
		}
		pass = "";
		ch = 0;
	} while (counter < 4);
	cout << "Due to your unverification of your I.D., you will not have access to the faculty reserved slots. \n You will have to park in the students' area.\n\n";
	return false;
If the user presses backspace you need to remove the last char from pass.
To remove the * from the screen you need to find a way to move the cursor backward and output a space.
Topic archived. No new replies allowed.