@@ -714,6 +714,75 @@ void rentBook(){
714
714
715
715
void searchBook (){
716
716
717
+ label4 :
718
+
719
+ system ("cls" );
720
+ fflush (stdin );
721
+
722
+ char name [255 ], author [255 ], publisher [255 ];
723
+ double bookid , price , quantity ;
724
+
725
+ int flag = 0 ;
726
+ int compare ;
727
+
728
+ char find [255 ];
729
+ printf ("Enter the name of the book you want to see the detail: " );
730
+ gets (find );
731
+
732
+ FILE * pF = fopen ("book_Records.txt" , "r" );
733
+
734
+ while (fscanf (pF , "%s %s %s %lf %lf %lf \n" , name , author , publisher , & bookid , & quantity , & price ) != EOF )
735
+ {
736
+ compare = strcmp (find , name );
737
+
738
+ if (compare == 0 )
739
+ {
740
+
741
+ printf ("\n>>> Record Found <<< \n\n" );
742
+
743
+ printf ("-------------------------------\n" );
744
+ printf ("> Book Name: %s \n" , name );
745
+ printf ("> Auhtor: %s \n" , author );
746
+ printf ("> Publisher: %s\n" , publisher );
747
+ printf ("> Book ID: %.0lf \n" , bookid );
748
+ printf ("> Quantity: %.0lf \n" , quantity );
749
+ printf ("> Price: %.0lf \n" , price );
750
+ printf ("-------------------------------\n\n\n" );
751
+
752
+ flag = 1 ;
753
+ }
754
+ }
755
+
756
+ fclose (pF );
757
+
758
+ if (flag == 0 )
759
+ {
760
+ printf ("\n>>> Record Not Found <<< \n" );
761
+ }
762
+
763
+ fflush (stdin );
764
+
765
+ char input ;
766
+ printf ("\nDo you wanna search for more records [y/N]: " );
767
+ scanf ("%c" ,& input );
768
+
769
+ if (input == 'y' || input == 'Y' )
770
+ {
771
+ goto label4 ;
772
+ }
773
+ else if (input == 'n' || input == 'N' )
774
+ {
775
+ printf ("\nRedirecting to Book Panel." );
776
+ Sleep (2000 );
777
+ bookPanel ();
778
+ }
779
+ else
780
+ {
781
+ printf ("\nInvaild input. Redirecting to Book Panel." );
782
+ Sleep (2000 );
783
+ bookPanel ();
784
+ }
785
+
717
786
}
718
787
719
788
void deleteBook (){
0 commit comments