-
Notifications
You must be signed in to change notification settings - Fork 0
/
bank4.c
73 lines (67 loc) · 1.41 KB
/
bank4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <stdio.h>
#include <string.h>
struct user{
char username[20];
char pin[4];
char security_question[50];
char security_answer[20];
};
void view_pin(struct user u)
{
printf("Pin: %s\n", u.pin);
}
void view_security_question(struct user u)
{
printf("Security Question: %s\n", u.security_question);
}
void reset_password(struct user *u)
{
char new_password[20];
printf("Enter new password: \n");
scanf("%s", new_password);
strcpy(u->pin, new_password);
printf("Password reset successful.\n");
}
void reset_profile_password(struct user *u)
{
char new_security_answer[20];
printf("Enter new security answer: \n");
scanf("%s", new_security_answer);
strcpy(u->security_answer, new_security_answer);
printf("Security answer reset successful.\n");
}
int main()
{
int choice;
struct user current_user = {"John Doe", "1234", "What is your favorite color?", "Blue"};
printf("Welcome %s\n", current_user.username);
while(1){
printf("\n1. View Pin\n");
printf("2. View Security Question\n");
printf("3. Reset Password\n");
printf("4. Reset Profile Password\n");
printf("5. Exit\n");
printf("Enter your choice: \n");
scanf("%d", &choice);
switch(choice){
case 1:
view_pin(current_user);
break;
case 2:
view_security_question(current_user);
break;
case 3:
reset_password(¤t_user);
break;
case 4:
reset_profile_password(¤t_user);
break;
case 5:
return 0;
default:
printf("Invalid choice. Please try again.\n");
break;
}
}
return 0;
}