Skip to content

Commit 435a5f7

Browse files
committed
Added Search Book Module
1 parent e665c5e commit 435a5f7

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

Project-File/Library-Management-System.c

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,75 @@ void rentBook(){
714714

715715
void searchBook(){
716716

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+
717786
}
718787

719788
void deleteBook(){

0 commit comments

Comments
 (0)