#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!

Recommended Answers

All 2 Replies

include the header string.h for string functions like strcmp

as a sidenote I'd suggest that you avoid using goto, instead you could use simpler methods like a switch condition

Did you used microsoft windows' function \ libs?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.