Try something like this instead of your
while(encrypt!=13) loop:
while(encrypt != 13)
{
if(encrypt!='\b')
{
Password.push_back(encrypt);
cout << '*';
}
else if(Password.length()>0) // Backspace only when possible
{
Password.resize(Password.length()-1); // Will also erase the last character
cout<<"\b \b"; // Inserts a space in place of the previous asterisk and moves to the desired location
}
encrypt = _getch();
}
Last edited by unbeatable0; Apr 14th, 2009 at 9:45 am.
Reputation Points: 42
Solved Threads: 13
Junior Poster in Training
Offline 90 posts
since Sep 2008