-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
163 lines (153 loc) · 4.74 KB
/
main.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <stdbool.h>
#include <string.h>
#include <windows.h>
#include "modules/login.c"
#include "modules/loading_screen.c"
#define MAX 100
void loadingScreen();
void lock();
void credits();
void login();
void lock()
{
int option;
int exitProgram = false; // Initialize exitProgram to false
do
{
system("cls");
system("color A");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t \xdb\xdb\xdb\xb3Mall InfoSys\xb3\xdb\xdb\xdb\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\n\t\t\xb3\xb0\xb3 Welcome \xb3\xb0\xb3\n\n");
printf("\t\t1. Login\n");
printf("\t\t2. Exit\n");
printf("\t\t-------------\n");
printf("\t\tOption -> ");
scanf("%d", &option);
switch (option)
{
case 1:
system("cls");
login();
break;
case 2:
exitProgram = true; // Update the exitProgram flag to true
break;
default:
system("cls");
system("color C");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t \xdb\xdb\xdb\xb3Warning\xb3\xdb\xdb\xdb\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\n\t\t\t\t\tInvalid option! Press enter to continue.\n\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
getch();
system("cls");
system("color A");
}
if (!exitProgram)
{
system("cls");
}
} while (!exitProgram);
system("cls");
credits();
system("cls");
exit(0);
}
void ac_set()
{
system("color A");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t \xdb\xdb\xdb\xb3Mall InfoSys\xb3\xdb\xdb\xdb\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\n\t\t\xb3\xb0\xb3 Create Account \xb3\xb0\xb3\n\n");
char user_name[MAX], password[MAX];
FILE *user;
user = fopen("data\\user_logs.txt", "w");
if (user == NULL)
{
printf("Failed to create about.dat\n");
exit(1);
}
printf("\t\tUsername -> ");
scanf(" %[^\n]s", user_name);
printf("\t\tPassword -> ");
scanf(" %[^\n]s", password);
fprintf(user, "\n%s\t%s\t%s", user_name, password, "admin");
printf("\t\tPress enter to continue!");
getch();
fclose(user);
system("cls");
}
void mall_details()
{
system("color A");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t \xdb\xdb\xdb\xb3Mall InfoSys\xb3\xdb\xdb\xdb\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\n\t\t\xb3\xb0\xb3 Mall Details \xb3\xb0\xb3\n\n");
mall_info info;
FILE *mall;
mall = fopen("data\\about.dat", "wb");
if (mall == NULL)
{
printf("Failed to create about.dat\n");
exit(1);
}
printf("\t\tMall Name -> ");
scanf(" %[^\n]s", info.mall_name);
printf("\t\tMall Address -> ");
scanf(" %[^\n]s", info.mall_address);
printf("\t\tMall Floors -> ");
scanf("%d", &info.mall_floor);
printf("\t\tMall Stores -> ");
scanf("%d", &info.mall_stores);
printf("\t\tMall Phone -> ");
scanf(" %[^\n]s", info.mall_phone);
printf("\t\tMall Email -> ");
scanf(" %[^\n]s", info.mall_email);
fwrite(&info, sizeof(mall_info), 1, mall);
printf("\t\tPress enter to continue!");
getch();
fclose(mall);
system("cls");
}
void credits()
{
system("color B");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t\xdb\xdb\xdb\xb3Support this project\xb3\xdb\xdb\xdb\n");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\t\t\t\t\t\t|| Contribute and Share\n");
printf("\t\t\t\t\t\t|| Give star on Github\n");
printf("\t\t\t\t\t\t|| %s\n", "https://github.com/ashish-shr");
printf("\t\t-------------------------------------------------------------------------------------------\n");
printf("\n\t\tPress enter to exit! ");
getch();
system("cls");
system("color A");
}
int main()
{
system("cls");
system("color A");
loadingScreen();
mall = fopen("data\\about.dat", "rb");
user = fopen("data\\user_logs.txt", "r");
if (mall == NULL || user == NULL)
{
mall_details();
ac_set();
}
fclose(mall);
fclose(user);
lock();
home();
system("cls");
return 0;
}