Backspace being printed as a character.. why?

i have a program, which uses a password inputation but when i made the password encrypted. when inputting my password which now appear as star(***) due to encryption. trying to delete a character but backspace is being read as a character. please can someone show me the way forward... thanks

1
2
3
4
5
6
7
8
cout << "Password: ";
encrypt = _getch();
   while(encrypt != 13)

   { 
	   Password.push_back(encrypt);
	  cout << '*';
      encrypt = _getch();
Last edited on
getch returns a char (or two) for any key that is pressed, including non-printable and function keys. It does not, however, return the escape sequence that you are expecting. You could use something like:
1
2
if(encrypt == /*backspace*/)
    cout << "\b \b";
Topic archived. No new replies allowed.