password as ********

uhm.... excuse me but can you please help me? i'm having trouble with making password in c++.... the condition goes like this, while the user is entering a password, the user will not see alpha-numeric characters instead, he/ she can see only asterisk... can you please tell me the code?????
You can use the function getch(). This function doesn't wait for input, and doesnt show it either: it simple returns an int of a key or, when no key is pressed, 0. For enter it returns 13:
1
2
3
4
5
6
7
8
9
10
11
string input;
int temp;
do
{
temp=getch();
if (temp!=0 && temp !=13)
{
    input+=(char)temp;
    cout<<"*";
}
}while (temp != 13);
Last edited on
oh... thank you! ^-^
Topic archived. No new replies allowed.