Skip to content

Commit 4f20095

Browse files
committed
Added Delete Book Module
1 parent 0c74911 commit 4f20095

File tree

2 files changed

+73
-2
lines changed

2 files changed

+73
-2
lines changed

Project-File/Library-Management-System.c

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ void modifyBook(){
743743
printf("\n\n-------------------------------\n");
744744
printf(">>> Record Not Found <<<\n");
745745
printf("-------------------------------\n\n");
746-
printf("Redirecting to User Panel...");
746+
printf("Redirecting to Book Panel...");
747747
}
748748

749749
pF = fopen("book_Records.txt", "a");
@@ -881,4 +881,76 @@ void searchBook(){
881881

882882
void deleteBook(){
883883

884+
system("cls");
885+
fflush(stdin);
886+
887+
char name[255], author[255], publisher[255];
888+
double bookid, price, quantity;
889+
890+
char name1[255], author1[255], publisher1[255];
891+
double bookid1, price1, quantity1;
892+
893+
int flag=0;
894+
int compare;
895+
896+
char find[255];
897+
printf("Enter the name of the book you want to delete the detail: ");
898+
gets(find);
899+
900+
fflush(stdin);
901+
902+
FILE *pF = fopen("book_Records.txt", "r");
903+
FILE *pT = fopen("temporary.txt", "a");
904+
905+
while(fscanf(pF, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
906+
{
907+
compare = strcmp(find, name);
908+
909+
if(compare == 0)
910+
{
911+
printf("\n---------------------------------------------\n");
912+
printf(">>> Record Deleted <<<\n");
913+
printf("-----------------------------------------------\n\n");
914+
printf("Redirecting to Book Panel...");
915+
916+
flag = 1;
917+
}
918+
else
919+
{
920+
fprintf(pT, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
921+
}
922+
}
923+
924+
fclose(pF);
925+
fclose(pT);
926+
927+
fflush(stdin);
928+
929+
pF = fopen("book_Records.txt", "w");
930+
fclose(pF);
931+
932+
if(flag == 0)
933+
{
934+
printf("\n\n-------------------------------\n");
935+
printf(">>> Record Not Found <<<\n");
936+
printf("-------------------------------\n\n");
937+
printf("Redirecting to Book Panel...");
938+
}
939+
940+
pF = fopen("book_Records.txt", "a");
941+
pT = fopen("temporary.txt", "r");
942+
943+
while(fscanf(pT, "%s %s %s %lf %lf %lf \n", name, author, publisher, &bookid, &quantity, &price) != EOF)
944+
{
945+
fprintf(pF, "%s %s %s %.0lf %.0lf %.0lf \n", name, author, publisher, bookid, quantity, price);
946+
}
947+
948+
fclose(pF);
949+
fclose(pT);
950+
951+
pT = fopen("temporary.txt", "w");
952+
fclose(pT);
953+
954+
Sleep(2000);
955+
bookPanel();
884956
}

Project-File/book_Records.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,3 @@ Shogun James Standford 12 5 50
33
Eillpsis Newton Oxford 13 15 110
44
Candide Voltaire Nalanda 14 15 120
55
Beloved Toni DTU 15 10 100
6-
Test Alkaison Intejii 16 10 1000

0 commit comments

Comments
 (0)