PROGRAM TO MASK THE PASSWORD WITH * IN C++

//Example of password masking in CPP with * sign.
#include<iostream.h>
#include<conio.h>
#include<string.h>

void main()
{
char pwd[]="password",verify[20], ch;
int i=0;
clrscr();
cout<<"Enter the password to verify: ";

do
{
ch=getch();
if(ch!=13)
{
verify[i++]=ch;
cout<<"*";
}
else
{
verify[i++]='\0';
}
}while(ch!=13);          //13 IS THE ASCII OF ENTER

if(strcmp(pwd,verify)==0)
cout<<"\nPassword Matched...";
else
cout<<"\nWrong Password...";
getch();
}
Powered by Blogger.