#include<stdio.h>
#include<stdlib.h>
int main()
{
char *pwd=NULL;
char *buff=NULL;
pwd=(char *)malloc(sizeof(char)*10);
buff=(char *)malloc(sizeof(char)*10);
int i=0,j,ret=0;
int ch;
FILE *fptr=NULL;
printf(“enter the password”);
scanf(“%s”,pwd);
fptr=fopen(“file.txt”,”r”);
if(fptr<0)
{
perror(“fopen”);
return(-1);
}
ch=fgetc(fptr);
for(j=0;j<3;j++)
{
while(ch!=EOF)
{
if(ch!=’\n’)
{
buff[i] = ch;
i++;
}
else
{
ret=strcmp(pwd,buff);
if(ret==0)
{
printf(“login successfully”);
exit(1);
}
else
{
i=0;
}
}
ch=getc(fptr);
}
if(ch==EOF)
{
printf(“try again\n”);
printf(“enter the password”);
scanf(“%s”,pwd);
if(j==2)
{
printf(“\nyou have tried maximum time.\nyour password is blocked\n”);
return (-1);
}
}
}
return 0;
}