Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Regarding password changing function in c

Deepak ChiradoniDeepak Chiradoni Member Posts: 1

Dear All,

I have written a code for password management in C. I need to change password from default password. I am not getting output. Its not overwriting. I have attached my code. Please help. Thanks in advance.

include <stdio.h>

include <string.h>

include <conio.h>

include <stdlib.h>

char loginpassword[10];
int Current_mode = 2;
int num;
int value_store;

void change_password(void);
char *Password_Ascii_function(void);

int main (void)

{

printf("Password Manager:\n");

char defaultascii[5] = "1234", count;

char *returnacii;

strcpy(loginpassword ,"Enter Password");

printf(loginpassword);

printf("\n");

while(1)
{

        returnacii = Password_Ascii_function(); 

        if(strcmp(returnacii, defaultascii)==0)
        {   
            returnacii[0] = '0';
            returnacii[1] = '0';
            returnacii[2] = '0';
            returnacii[3] = '0';

            strcpy(loginpassword, "Enter New Password");

            printf("\n");

            printf(loginpassword);

            printf("\n");

            returnacii = Password_Ascii_function();

            defaultascii[0] = returnacii[0];
            defaultascii[1] = returnacii[1];
            defaultascii[2] = returnacii[2];
            defaultascii[3] = returnacii[3];

            printf("\n");

            printf("Password changed, Login again:");

            printf("\n");

            main();                    
        }
        else
        {
            strcpy(loginpassword,"Wrong Password");

            count=count+1;

            if(count>=4)
            {
                strcpy(loginpassword,"Default Password");

                printf(loginpassword);

                defaultascii[0] = '1';
                defaultascii[1] = '2';
                defaultascii[2] = '3';
                defaultascii[3] = '4';
                defaultascii[4] = '\0';                     

                strcpy(loginpassword, defaultascii);
            }
         }

    printf(loginpassword);

}

getch();
return 0;

}

char *Password_Ascii_function(void)
{

char pasword[10],usrname[10], ch;
int i;

  for(i=0;i<4;i++)
    {
        ch = getch();
        pasword[i] = ch;
        ch = '*' ;
        printf("%c",ch);
    }

   pasword[i] = '\0';

   return pasword;

}

Thanks
Deepak

Tagged:
Sign In or Register to comment.