-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathvalidatePassword.c
More file actions
41 lines (32 loc) · 820 Bytes
/
validatePassword.c
File metadata and controls
41 lines (32 loc) · 820 Bytes
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
#include "bwave.h"
/**
* validatePassword - This functionn validates the password of user.
* Return: 1 if successful
*/
int validatePassword(const char* password) {
char val[MIN_LENGTH];
int value;
int i = 3;
printf("Re-enter your password: ");
scanf("%s", val);
value = strcmp(password, val);
if (value != 0) {
while (i >= 0) {
printf("\n Your passwords don't match \n");
printf("Try again, Re-enter your password: ");
scanf("%s", val);
value = strcmp(password, val);
if (value == 0) {
return 1; // Password validation successful
}
if (i > 0)
printf("Passwords don't match. You have %d more attempts \n", i);
else
printf("Your account is locked");
i--;
}
} else {
return 1; // Password validation successful
}
return 0; // Password validation failed
}