This is the program i have written can anyone tell what is wrong with it, because whatever input i give, it shows valid user.
#include<stdio.h>
#include<string.h>
#define max_size 20
void main()
{
File *Fptr;
char username[max_size];
char line[20];
if((fptr=fopen("/etc/passwd","r"))==NULL)
{
printf("cannot open file");
}
else
{
fptr=fopen("/etc/passwd","r");
fputs("enter the username",stdout);
fflush(stdout);
fgets(username,sizeof username,stdin);
while((fgets(line,sizeof(line),fptr))!=NULL)
{
if(strcmp(line,username))
{
printf("%s valid user",username);
break;
}
else
{
printf("%s not valid user",username);
}
}
fclose(fptr);
}
}