hey guys, i'm using Borland 6 c++ in windows xp, now that we got that i have a problem with my program, i have recently created a password function in a programm that works so that when they try to type in their password it shows the * instead of the character for security measures (and just cus it is cool too lol) but the problem is that when someone makes a typo and wants to delete a character it still displays another *, is there a way that i can make the programm destroy one character when the backspace button is struck? here is my function so that you guys can look at it too.
#include <iostream>
#include <conio>
#include <condefs.h>
#pragma hdrstop
#pragma argsused
string EnterPassword(){
string numAsString = "";
char ch = getch();
while (ch != '\r') {
cout << '*';
numAsString += ch;
ch = getch();
}
return numAsString;
}
void passfunction();
int main(int argc, char **argv)
{
passfunction();
return 0;
}
void passfunction()
{
cout << endl;
cout << "password:";
string password = EnterPassword();
if( passowrd == "rbrown" ){
cout << "Hello Mr. Brown, Welcome back" << endl;
system("PAUSE");
leave = true;
return;
}
else if (password != "rbrown"){
cout << "incorrect password, please try again." << endl;
system("PAUSE");
leave = false;
passfunction (leave);
}
cout << password << endl;
system("PAUSE");
return;
}