#include "stdio.h"
int main()
{
//FILE *fp;
char get[20] ;
char password[15];
int choice;
choice:
printf("\nSELETCT: 1.Login 2.Password change 0.Exit \n");
scanf("%d", &choice);
if(choice == 1)
{
FILE *fp;
fp = fopen("PASS.txt","r");
fgets(password,15,fp);
printf("your current password is %s\n", password);
printf("Enter password: ");
scanf("%s",get);
if( !strcmp(get, password) )
{
printf("\n%s\n", "Logged on succesfully!");
goto choice;
}
else
{
printf("\n%s\n", "Incorrect login!");
goto choice;
}
}
else if(choice == 2)
{ FILE *ft,*oldfl;
char newpass[15];
char cmp[15];
printf("enter the old password:");
scanf("%s",get);
oldfl = fopen("PASS.txt","r");
fgets(cmp,15,oldfl);
if(!strcmp(get,cmp))
{
ft = fopen("PASS.txt","w");
printf("\nenter the new password:" );
scanf("%s",get);
fputs(get,ft);
fclose(ft);
printf("\n Password Changed Successfully\n");
goto choice;
}
else
{
printf("\nyou entered old password is wrong\n");
goto choice;
}
}
}
Someone help me out!