#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char *pwd=NULL;
int ch=0,i=0,ret;
char *buff;
pwd=malloc(sizeof(char) *10);
buff=malloc(sizeof(char) *10);
FILE *fptr = NULL;
fptr=fopen(“hello.txt”,”r+”);
if(fptr == NULL)
{
perror(“fopen”);
return -1;
}
else
printf(“file is opened successfully\n”);
printf(“enter the password\n”);
gets(pwd);
ch=getc(fptr);
while(ch!=EOF)
{
if(ch!=’\n’)
{
buff[i]=ch;
ch=getc(fptr);
i++;
}
else
{
ret=strcmp(buff,pwd);
if(ret==0)
{
printf(“login successfully..\n”);
exit(0);
}
else
{
i=0;
ch=fgetc(fptr);
}
}
}
if(ch==EOF)
{
printf(“wrong password..try again\n”);
}
return 0;
}