achar.deepak
Member level 1
Dear All,
I have written a code for password managing function in C. I need to change the password from default password. I have attached my code. The password is not updating. Please help. Thanks in advance.
Regards
Deepak A B C
I have written a code for password managing function in C. I need to change the password from default password. I have attached my code. The password is not updating. Please help. Thanks in advance.
Code:
#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;
}
Regards
Deepak A B C