today we will see a program which is written in c programming language to create a login page , the best part is here is , the password will be hidden for others , means , when you will type your password , others will see '*' marks....like
Username :: sherlock
Password :: *******
so here is my code ,
#include<stdio.h>
#include<conio.h>
#include<string.h>
char username[20],password[20];
void main()
{
char *c;
while(1)
{
printf("Username :: ");
gets(username);
printf("Password ::");
c=password;
while(1)
{
*c=getch();
if(*c!=13)
{
printf("*");
c++;
}
else
{
*c='\0';
break;
}
}
if(strcmp(username,"sherlock")==0 && strcmp(password,"12345")==0)
{
break;
}
else
{
printf("\nusername or password is incorrect\n");
}
}
clrscr();
printf("\n hi , you are succesfully logged in");
getch();
return;
}
thank you,
Username :: sherlock
Password :: *******
so here is my code ,
#include<stdio.h>
#include<conio.h>
#include<string.h>
char username[20],password[20];
void main()
{
char *c;
while(1)
{
printf("Username :: ");
gets(username);
printf("Password ::");
c=password;
while(1)
{
*c=getch();
if(*c!=13)
{
printf("*");
c++;
}
else
{
*c='\0';
break;
}
}
if(strcmp(username,"sherlock")==0 && strcmp(password,"12345")==0)
{
break;
}
else
{
printf("\nusername or password is incorrect\n");
}
}
clrscr();
printf("\n hi , you are succesfully logged in");
getch();
return;
}
thank you,
0 Comments