Masking of String with * as password input in C Programming.



#include<stdio.h>
int main()
{
char pwd[20],ch;
char mypwd[]="Hello";
int i=0;
printf("Enter Password: ");
do
{
ch=getch();
if(ch!=13)
{
printf("*");
pwd[i++]=ch;
}
else
{
pwd[i]='\0';
}
}while(ch!=13);
printf("\nEntered password is %s\n",pwd);

if(strcmp(mypwd,pwd)==0)
{
printf("Password Matched....\n");
}
else
{
printf("Password MisMatched....\n");
}
getch();
}



See the video for explanation through following link.




No comments

Post your comments

Powered by Blogger.