-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString Database Example
More file actions
102 lines (41 loc) · 1.2 KB
/
Copy pathString Database Example
File metadata and controls
102 lines (41 loc) · 1.2 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// my small database which is GLOBAL
char un1[30] = "Rebeca";
char pw1[30] = "R334vm";
char un2[30] = "dilmorad";
char pw2[30] = "d123d123";
char un3[30] = "Emmanual";
char pw3[30] = "ntum1emma";
int checkIdentity(char un[], char pw[])
{
// check the inputs and tell us which item is wrong
// it returns 1 if both are correct
// it returns -1 if un is wrong
// it returns -2 if pw is wrong
if ((strcmp(un,un1) == 0) && (strcmp(pw,pw1) == 0))
return 1;
if (strcmp(un,un1) != 0)
return -1;
if ((strcmp(un,un1) == 0) && (strcmp(pw,pw1) != 0))
return -2;
}
int main()
{
// username and password variables
char username[30] = "";
char password[30] = "";
printf("Welcome to our company!\n");
printf("Please enter your username: ");
gets(username);
printf("Thank you! Please enter your password: ");
gets(password);
if (checkIdentity(username, password) == 1)
printf("Congradulation! You have been successfully logged in!\n");
else if (checkIdentity(username, password) == -1)
printf("Wrong username!\n");
else if (checkIdentity(username, password) == -2)
printf("Wrong password!\n");
return 0;
}