C Program to Validate Input using String Functions
This is the c program to validate input using string functions,it checks whether username and password matches and if yes it provides access else not
#include<stdio.h>
#include<string.h>
main()
{
char psswd[]="beinghuman";
char inp[30];
int i=0;
int n=5;
printf("LOGIN REQUIRED n");
while(strcmp(psswd,inp)!=0)
{
i++;
printf("Enter the Password You Have %d tries left n",n);
scanf("%s",inp);
n=n-i;
if(i==5)
{
printf("ACCOUNT BLOCKED n");
break;
}
if(strcmp(psswd,inp)==0)
{
printf("ACCESS GRANTED n");
}
}
}
Recent Comments