@@ -743,7 +743,7 @@ void modifyBook(){
743
743
printf ("\n\n-------------------------------\n" );
744
744
printf (">>> Record Not Found <<<\n" );
745
745
printf ("-------------------------------\n\n" );
746
- printf ("Redirecting to User Panel..." );
746
+ printf ("Redirecting to Book Panel..." );
747
747
}
748
748
749
749
pF = fopen ("book_Records.txt" , "a" );
@@ -881,4 +881,76 @@ void searchBook(){
881
881
882
882
void deleteBook (){
883
883
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 ();
884
956
}
0 commit comments