|
CPP Program For Password Echo |
#include
#include
void main()
{
clrscr();
cout<<"Enter password: \n";
restart:int x[100],x1[100],i,j=0,k=0,l;
for(i=0;i<=100;i++)
{
shahab:l=getch();
if(((l>=48)&&(l<=126))||(l==8)||(l==13))x[i]=l;
else goto shahab;
if(x[i]==13)break;
else if(x[i]==8)
{
gotoxy(1,2);
clreol();
for(i=0;i<100;i++)
x[i]='\0';
goto restart;
}
else
{
cout<<"*";
k++;
}
}
cout<<"\nRe enter password: \n";
for(i=0;i<=k;i++)
{
x1[i]=getche();
if(x1[i]==13)break;
}
for(i=0;i<=k;i++)
if(x[i]!=x1[i])j++; if(j==0)
cout<<"\nPasswords match!!\n";
else
cout<<"\nPasswords do not match!!\n";
getch();
}
Sample Input :
Enter password:
*****
Re enter password:
hello
Passwords match!!
Enter password:
*****
Re enter password:
hai
Passwords do not match!!
|
|
|