I am using this function to show me invalid password when the user password does not matches but it always open encrypt decrypt function for me!
char username[50], pword[50]; struct user usr;
printf("\nEnter your username:\t");
takeinput(usr.username);
printf("Enter your password:\t");
takepassword();
fp = fopen("Users.dat", "r");
while (fread(&usr, sizeof(struct user), 1, fp))
{
if (strcmp(usr.username, username))
{
if (strcmp(usr.password, pword))
{
system("cls");
printf("\n\t\t\t\t\t\tWelcome\n");
encrypt_decrypt();
}
else if ((!strcmp(usr.password, pword)))
// if password is not matching with user password
{
printf("\n\nInvalid Password!");
}
usrFound = 1;
}
}
if (!usrFound)
{
printf("\n\nUser is not registered!");
}
fclose(fp);
break;