-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.c
1125 lines (879 loc) · 27.3 KB
/
lib.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#include<windows.h>
// Define Constant KeyWords
#define ENTER 13
#define TAB 9
#define BKSP 8
// System Operation Functions
void password(void);
void menu(void);
void userPanel(void);
void bookPanel(void);
void endScreen(void);
// User Operation Functions
void addUser(void);
void modifyUser(void);
void listUser(void);
int searchUser(int);
void rentList(void);
void deleteUser(void);
// Book Operation Functions
void addBook(void);
int modifyBook(int);
void listBook(void);
void rentBook(void);
int searchBook(int);
void deleteBook(void);
// Main Function
void main(){
password();
}
// System Functions
int passTerminator = 1;
int bookStock = 0;
char rentName[255], bookName[255];
// If the user enters invaild password 3 times then the program gets terminated.
// Password: Alkaison
void password(){
system("cls");
fflush(stdin);
char pwd[255];
char code[255] = {"NIT"};
int i = 0;
char ch;
printf("--------------------\n");
printf(">>> Login First <<<\n");
printf("--------------------\n\n");
printf("Enter your password. Hit ENTER to confirm. \n");
printf("Password:");
while(1)
{
ch = getch(); // get key
if(ch == ENTER || ch == TAB)
{
pwd[i] = '\0';
break;
}
else if(ch == BKSP)
{
if(i > 0)
{
i--;
printf("\b \b"); // for backspace
}
}
else
{
pwd[i++] = ch;
printf("* \b"); // to replace password character with *
}
}
fflush(stdin);
// verifies the password
if(strcmp(code, pwd) == 0)
{
printf("\nCorrect Password!");
Sleep(5000);
menu();
}
else
{
printf("\nInvaild Password!");
(passTerminator == 3) ? exit(0) : passTerminator++;
Sleep(5000);
password();
}
}
// Main Selection menu between User & Book Panel
void menu(){
system("cls");
fflush(stdin);
int number;
printf("----------------------------------\n");
printf(">>> Library Management System <<< \n");
printf("----------------------------------\n\n");
printf("> 1. User Management Panel \n");
printf("> 2. Book Management Panel \n\n");
printf("> Enter the number & hit ENTER: ");
scanf("%d",&number);
fflush(stdin);
switch(number)
{
case 1:
userPanel();
break;
case 2:
bookPanel();
break;
default:
printf("\n>>> Invaild Input! <<<");
Sleep(9000);
menu();
}
}
// User Panel sub-functions
void userPanel(){
system("cls");
fflush(stdin);
int number;
printf("-----------------------------------------------\n");
printf(">>> Library Management System - User Panel <<< \n");
printf("-----------------------------------------------\n\n");
printf("> 1. Add User \n");
printf("> 2. Modify User \n");
printf("> 3. List User \n");
printf("> 4. List Rentals \n");
printf("> 5. Search User \n");
printf("> 6. Delete User \n");
printf("> 7. Open Main Menu \n");
printf("> 8. Close the Program... \n\n");
printf("> Enter the number & hit ENTER: ");
scanf("%d",&number);
fflush(stdin);
switch(number)
{
case 1:
addUser();
break;
case 2:
modifyUser();
break;
case 3:
listUser();
break;
case 4:
rentList();
break;
case 5:
searchUser(0);
break;
case 6:
deleteUser();
break;
case 7:
menu();
break;
case 8:
endScreen();
break;
default:
printf("Invaild Input!");
Sleep(9000);
userPanel();
}
}
// Book Panel sub-functions
void bookPanel(){
system("cls");
fflush(stdin);
int number;
printf("-----------------------------------------------\n");
printf(">>> Library Management System - Book Panel <<< \n");
printf("-----------------------------------------------\n\n");
printf("> 1. Add Book \n");
printf("> 2. Modify Book \n");
printf("> 3. List Book \n");
printf("> 4. Rent Book \n");
printf("> 5. Search Book \n");
printf("> 6. Delete Book \n");
printf("> 7. Open Main Menu \n");
printf("> 8. Close the Program... \n");
printf("\nEnter the number & hit ENTER: ");
scanf("%d",&number);
fflush(stdin);
switch(number)
{
case 1:
addBook();
break;
case 2:
modifyBook(0);
break;
case 3:
listBook();
break;
case 4:
rentBook();
break;
case 5:
searchBook(0);
break;
case 6:
deleteBook();
break;
case 7:
menu();
break;
case 8:
endScreen();
break;
default:
printf("Invaild Input!");
Sleep(9000);
bookPanel();
}
}
void endScreen(){
system("cls");
fflush(stdin);
printf("----------------------------------------------\n");
printf("----------------------------------------------\n\n");
exit(0);
}
// User Functions
// Creates new file if old doesn't exist and saves user records in it
void addUser(){
label1:
system("cls");
fflush(stdin);
char fname[255], lname[255];
char gender;
double sid, phone, balance;
FILE *pF = fopen("user_Records.txt", "ab+");
if(pF != NULL)
{
printf("Enter the First Name: ");
gets(fname) ;
printf("Enter the Last Name: ");
gets(lname);
printf("Enter Gender [M/F]: ");
scanf("%c",&gender);
printf("Enter Student ID: ");
scanf("%lf",&sid);
printf("Enter Phone Number: ");
scanf("%lf",&phone);
fprintf(pF, "%s %s %c %.0lf %.0lf \n", fname, lname, gender, sid, phone);
printf("\n>>> User Record Added Successfully <<< \n");
}
else
{
printf("Unable to open/locate the file.");
}
fclose(pF);
fflush(stdin);
//retry screen
char input;
printf("\nDo you wanna enter more records [y/N]: ");
scanf("%c",&input);
if(input == 'y' || input=='Y')
{
goto label1;
}
else if(input=='n' || input=='N')
{
printf("\nRedirecting to User Panel.");
Sleep(9000);
userPanel();
}
else
{
printf("\nInvaild input. Redirecting to User Panel.");
Sleep(9000);
userPanel();
}
}
// Edit the user details and saves it
void modifyUser(){
system("cls");
fflush(stdin);
char fname[255], lname[255], gender[5];
char fname1[255], lname1[255], gender1[5];
double sid, sid1, phone, phone1;
int compare, flag=0;
char find[255];
printf("Enter the name of the person you want to modify the detail: ");
gets(find);
fflush(stdin);
FILE *pF = fopen("user_Records.txt", "r");
FILE *pT = fopen("temporary.txt", "a");
while(fscanf(pF, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
compare = strcmp(find, fname);
if(compare == 0)
{
printf("\n---------------------------------------------\n");
printf(">>> Record Found, Allowing Modifications <<<\n");
printf("-----------------------------------------------\n\n");
printf("> Enter First Name: ");
gets(fname1);
printf("> Enter Last Name: ");
gets(lname1);
printf("> Enter Gender: ");
gets(gender1);
printf("> Enter Student ID: ");
scanf("%lf",&sid1);
printf("> Enter Phone Number: ");
scanf("%lf",&phone1);
fprintf(pT, "%s %s %s %.0lf %.0lf \n",fname1, lname1, gender1, sid1, phone1);
printf("\n\nProcessing your changes....");
flag = 1;
}
else
{
fprintf(pT, "%s %s %s %.0lf %.0lf \n",fname, lname, gender, sid, phone);
}
}
fclose(pF);
fclose(pT);
fflush(stdin);
pF = fopen("user_Records.txt", "w");
fclose(pF);
if(flag == 0)
{
printf("\n\n-------------------------------\n");
printf(">>> Record Not Found <<<\n");
printf("-------------------------------\n\n");
printf("Redirecting to User Panel...");
}
pF = fopen("user_Records.txt", "a");
pT = fopen("temporary.txt", "r");
while(fscanf(pT, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
fprintf(pF, "%s %s %s %.0lf %.0lf \n", fname, lname, gender, sid, phone);
}
fclose(pF);
fclose(pT);
pT = fopen("temporary.txt", "w");
fclose(pT);
fflush(stdin);
Sleep(9000);
userPanel();
}
// Lists all the user records from user_Records.txt file
void listUser(){
system("cls");
fflush(stdin);
FILE *pF = fopen("user_Records.txt", "r");
char fname[255], lname[255], gender[5];
double sid, phone;
int counter=0;
printf("-------------------------------\n");
printf(">>> List of Users Record <<< \n");
printf("-------------------------------\n\n");
while(fscanf(pF, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
strcat(fname, " ");
strcat(fname, lname);
printf("-------------------------------\n");
printf("> Full Name: %s \n", fname);
printf("> Gender: %s \n", gender);
printf("> Student-ID: %.0lf \n", sid);
printf("> Phone No.: %.0lf \n", phone);
printf("-------------------------------\n\n\n");
counter++;
}
fclose(pF);
if(counter == 0)
{
printf("-------------------------------------\n");
printf("There is no user records added yet...\n");
printf("--------------------------------------\n\n");
}
printf("Press any key to get back to User Panel.\n");
getch();
userPanel();
}
// this checks if the specified user exists in the records or not
int searchUser(int nameSearcher){
label2:
system("cls");
fflush(stdin);
char fname[255], lname[255], gender[5];
double sid, phone;
int flag=0;
int compare;
char find[255];
(nameSearcher != 3) ? printf("Search by First name of the student: ") : printf("Search by First name of the student who wants to rent book: ");
gets(find);
FILE *pF = fopen("user_Records.txt", "r");
while(fscanf(pF, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
//strcmp(variable, variable1) -- if both the strings are equal then it will return 0 otherwise a random number.
compare = strcmp(find, fname);
if(compare == 0)
{
if(nameSearcher != 3)
{
strcat(fname, " ");
strcat(fname, lname);
printf("\n---------------------\n");
printf(">>> Record Found <<< \n");
printf("---------------------\n\n");
printf("-------------------------------\n");
printf("> Full Name: %s \n", fname);
printf("> Gender: %s \n", gender);
printf("> Student-ID: %.0lf \n", sid);
printf("> Phone Number: %.0lf \n", phone);
printf("-------------------------------\n\n");
}
strcpy(rentName, fname);
flag=1;
}
}
fclose(pF);
if(flag == 0)
{
printf("\n>>> Record Not Found <<< \n\n");
}
fflush(stdin);
if(nameSearcher != 3)
{
printf("Press any key to redirect back to Panel.");
getch();
userPanel();
}
else if(nameSearcher == 3 && flag == 1)
{
return 5;
}
}
// deletes the user information from user_Records.txt file
void deleteUser(){
system("cls");
fflush(stdin);
char fname[255], lname[255], gender[5];
char fname1[255], lname1[255], gender1[5];
double sid, sid1, phone, phone1;
int compare, flag=0;
char find[255];
printf("Enter the name of the person you want to delete the detail: ");
gets(find);
fflush(stdin);
FILE *pF = fopen("user_Records.txt", "r");
FILE *pT = fopen("temporary.txt", "a");
while(fscanf(pF, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
compare = strcmp(find, fname);
if(compare == 0)
{
printf("\n---------------------------------------------\n");
printf(">>> Record Deleted <<<\n");
printf("-----------------------------------------------\n\n");
printf("Redirecting to User Panel...");
flag = 1;
}
else
{
fprintf(pT, "%s %s %s %.0lf %.0lf \n",fname, lname, gender, sid, phone);
}
}
fclose(pF);
fclose(pT);
fflush(stdin);
pF = fopen("user_Records.txt", "w");
fclose(pF);
if(flag == 0)
{
printf("\n\n-------------------------------\n");
printf(">>> Record Not Found <<<\n");
printf("-------------------------------\n\n");
printf("Redirecting to User Panel...");
}
pF = fopen("user_Records.txt", "a");
pT = fopen("temporary.txt", "r");
while(fscanf(pT, "%s %s %s %lf %lf \n", fname, lname, gender, &sid, &phone) != EOF)
{
fprintf(pF, "%s %s %s %.0lf %.0lf \n", fname, lname, gender, sid, phone);
}
fclose(pF);
fclose(pT);
pT = fopen("temporary.txt", "w");
fclose(pT);
fflush(stdin);
Sleep(9000);
userPanel();
}
// Book Functions
// add the books record in book_Records.txt file
void addBook(){
label3:
system("cls");
fflush(stdin);
char name[255], author[255], publisher[255];
double bookid, quantity;
FILE *pF = fopen("book_Records.txt", "ab+");
if(pF != NULL)
{
printf("Enter Book Name: ");
gets(name);
printf("Enter Book Author: ");
gets(author);
printf("Enter Book Publisher: ");
gets(publisher);
fflush(stdin);
printf("Enter Book ID: ");
scanf("%lf",&bookid);
printf("Enter Book Quantity: ");
scanf("%lf",&quantity);
fprintf(pF, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
printf("\n>>> Book Record Added Successfully <<< \n");
}
else
{
printf("Unable to open/locate the file.");
}
fclose(pF);
fflush(stdin);
char input;
printf("\nDo you wanna enter more records [y/N]: ");
scanf("%c",&input);
if(input == 'y' || input=='Y')
{
goto label3;
}
else if(input=='n' || input=='N')
{
printf("\nRedirecting to Book Panel.");
Sleep(9000);
bookPanel();
}
else
{
printf("\nInvaild input. Redirecting to Book Panel.");
Sleep(9000);
bookPanel();
}
}
// edits the book details according to you and saves it again
int modifyBook(int rentModifier){
system("cls");
fflush(stdin);
char name[255], author[255], publisher[255];
double bookid, quantity;
char name1[255], author1[255], publisher1[255];
double bookid1, quantity1;
int flag=0;
int compare;
char find[255];
if (rentModifier != 5)
{
printf("Enter the name of the book you want to see the detail: ");
gets(find);
fflush(stdin);
}
else
{
strcpy(find, bookName);
}
FILE *pF = fopen("book_Records.txt", "r");
FILE *pT = fopen("temporary.txt", "a");
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
{
compare = strcmp(find, name);
if(compare == 0)
{
if(rentModifier != 5)
{
printf("\n---------------------------------------------\n");
printf(">>> Record Found, Allowing Modifications <<<\n");
printf("-----------------------------------------------\n\n");
printf("> Enter Book Name: ");
gets(name1);
printf("> Enter Authour: ");
gets(author1);
printf("> Enter Publisher: ");
gets(publisher1);
fflush(stdin);
printf("> Enter Book ID: ");
scanf("%lf",&bookid1);
printf("> Enter Quantity: ");
scanf("%lf",&quantity1);
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name1, author1, publisher1, bookid1, quantity1);
printf("\n\nProcessing your changes....");
}
else
{
quantity = bookStock;
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
}
flag = 1;
}
else
{
fprintf(pT, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
}
}
fclose(pF);
fclose(pT);
fflush(stdin);
pF = fopen("book_Records.txt", "w");
fclose(pF);
if(flag == 0)
{
printf("\n\n-------------------------------\n");
printf(">>> Record Not Found <<<\n");
printf("-------------------------------\n\n");
printf("Redirecting to Book Panel...");
}
pF = fopen("book_Records.txt", "a");
pT = fopen("temporary.txt", "r");
while(fscanf(pT, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
{
fprintf(pF, "%s %s %s %.0lf %.0lf \n", name, author, publisher, bookid, quantity);
}
fclose(pF);
fclose(pT);
pT = fopen("temporary.txt", "w");
fclose(pT);
if(rentModifier != 5)
{
Sleep(9000);
bookPanel();
}
}
// lists all the book record from the book_Records.txt file
void listBook(){
system("cls");
fflush(stdin);
char name[255], author[255], publisher[255];
double quantity, bookid;
int counter=0;
FILE *pF = fopen("book_Records.txt", "r");
printf("-------------------------------\n");
printf(">>> List of Books Record <<< \n");
printf("-------------------------------\n\n");
while(fscanf(pF, "%s %s %s %lf %lf \n", name, author, publisher, &bookid, &quantity) != EOF)
{
printf("-------------------------------\n");
printf("> Book Name: %s \n", name);
printf("> Auhtor: %s \n", author);
printf("> Publisher: %s\n", publisher);
printf("> Book ID: %.0lf \n", bookid);
printf("> Quantity: %.0lf \n", quantity);
printf("-------------------------------\n\n\n");
counter++;
}
fclose(pF);
if(counter == 0)
{
printf("-------------------------------------\n");
printf("There is no book records added yet...\n");
printf("--------------------------------------\n\n");
}
printf("Press any key to get back to Book Panel.\n");
getch();
bookPanel();
}
// Book Rental function
// first it checks whether the user is already registered in the user_Records.txt or not
// second it checks whether the book exists in the book_Records.txt or not
// third it checks if the book quantity is atleast 1, throws error if the book is OUT OF STOCK -- it also reduces book quantity by 1 from book_Recprds.txt
// fourth it registers the user name & book name in a new file rent_Records.txt and saves it
void rentBook(){
int terminator=1, nameFound, bookFound;
label5:
fflush(stdin);
// check if user exists
nameFound = searchUser(3);
if(nameFound != 5 && terminator != 4)
{
printf("Press any key to re-enter the name. \n");
getch();
(terminator == 3) ? bookPanel() : terminator++;
goto label5;
}
else if(nameFound == 5)
{
printf("\nUser Found in Records! \nPlease wait... \n");
terminator = 1;
Sleep(9000);
}
label6:
fflush(stdin);
// check if book exists
bookFound = searchBook(3);
if(bookFound != 5 && terminator != 4)
{
printf("Press any key to re-enter the name. \n");
getch();
(terminator == 3) ? bookPanel() : terminator++;
goto label6;
}
else if(bookFound == 5)
{
// check if book quantity is > 0
if(bookStock > 0)
{
printf("\nBook Found & In-Stock! \nPlease wait... \n");
}
else
{
printf("\nSorry, Out of Stock! \nPlease wait... ");
Sleep(9000);
(terminator == 3) ? bookPanel() : terminator++;
goto label6;
}
}
fflush(stdin);
/* printf("\n---------------------------------------------\n");
printf("User Searcher: %d \n", nameFound);
printf("Book Searcher: %d \n", bookFound);
printf("User Name: %s \n", rentName);
printf("Book Name: %s \n", bookName);
printf("---------------------------------------------\n\n"); */
if(nameFound == 5 && bookFound == 5)
{
// Adding record in rent_Records.txt file
FILE *pF = fopen("rent_Records.txt", "ab+");
if(pF != NULL)
{
fprintf(pF, "%s %s \n", rentName, bookName);
}
else
{
printf("Unable to open/locate the file.");
}
fclose(pF);
// reducing quantity of book by 1
bookStock--;
modifyBook(5);
printf("---------------------------------------------\n");
printf(">>> Rent Record Added Successfully <<< \n");
printf("---------------------------------------------\n");
printf("\nRedirecting to Book Panel...\n");
Sleep(9000);
bookPanel();
}
}
// lists all the username & booknames which are rented to someone in registered files
void rentList(){
system("cls");
fflush(stdin);
char rentListUser[255], rentListBook[255];
int counter = 0;
FILE *pF = fopen("rent_Records.txt", "r");
printf("-------------------------------\n");
printf(">>> List of Books Rental <<< \n");
printf("-------------------------------\n\n");
while(fscanf(pF, "%s %s \n", rentListUser, rentListBook) != EOF)
{
printf("> Rent User: %s \n", rentListUser);
printf("> Rent Book(s): %s \n\n", rentListBook);
counter++;
}
fclose(pF);
fflush(stdin);
if(counter == 0)
{
printf("-------------------------------------\n");
printf("There is no rent records added yet...\n");
printf("--------------------------------------\n\n");
}
printf("\nPress any key to get back to User Panel.\n");
getch();
userPanel();
}
// searches for the book details by book name from the txt file
int searchBook(int bookSearcher){
label4:
system("cls");
fflush(stdin);
char name[255], author[255], publisher[255];
double bookid, quantity;
int flag=0;
int compare;
char find[255];
(bookSearcher != 3) ? printf("Serach the book by Author name or Book name: ") : printf("Serach the book by Author name or Book name: ");
gets(find);
FILE *pF = fopen("book_Records.txt", "r");