ow is a menu-driven program about library operations. Help me because I don't know how to put an update and delete transactions. Also, please edit the program so it can have file manipulation/handling. Required input: CODE: #include #include #include struct book { int b_no;
C
Down below is a menu-driven program about library operations. Help me because I don't know how to put an update and delete transactions. Also, please edit the program so it can have file manipulation/handling.
Required input:
CODE:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct book
{
int b_no;
char b_name[40];
char b_author[40];
int no_pg;
};
int main()
{
struct book b[20];
int ch,n,i,count = 0;
char temp[40];
do
{
printf("\n**************************************\n");
printf("\nMENU DRIVEN LIBRARY OPERATIONS PROGRAM\n");
printf("\n**************************************\n");
printf("\n\nCHOOSE FROM THE GIVEN OPTIONS BELOW:\n");
printf("\n--------------------------------------------\n");
printf("\nPRESS 1 - TO ADD BOOK DETAILS");
printf("\nPRESS 2 - TO DISPLAY BOOK DETAILS");
printf("\nPRESS 3 - TO SEARCH A BOOK/S OF A GIVEN AUTHOR");
printf("\nPRESS 4 - TO EXIT\n");
printf("\n--------------------------------------------\n");
printf("Enter Your Choice: ");
scanf("%d",&ch);
switch(ch)
{
case 1:
printf("\nHow many records you want to add? : ");
scanf("%d",&n);
printf("-------------------------------------\n");
printf("ADD BOOK/S DETAILS\n",n);
printf("-------------------------------------\n");
for(i = 0 ; i < n ; i++)
{
printf("Enter Book Number : ");
scanf("%d",&b[i].b_no);
printf("Book Name : ");
scanf("%s",b[i].b_name);
printf("Enter Author Name : ");
scanf("%s",b[i].b_author);
printf("Enter Number of Pages : ");
scanf("%d",&b[i].no_pg);
printf("-------------------------------------\n");
}
break;
case 2:
printf("\n\t\tDETAILS OF THE BOOK/S");
printf("\n-----------------------------------------------------------\n");
printf("Book No. Book Name\t Author Name\tNo. of Pages");
printf("\n------------------------------------------------------------");
for( i = 0 ; i < n ; i++)
{
printf("\n %d\t %s\t %s\t %d",b[i].b_no,b[i].b_name,b[i].b_author,b[i].no_pg);
}
printf("\n\n");
break;
case 3:
printf("-------------------------------------\n");
printf("SEARCH A BOOK/S OF GIVEN AUTHOR\n",n);
printf("-------------------------------------\n");
printf("\nEnter Author Name: ");
scanf("%s",temp);
printf("--------------------------------------");
for( i = 0 ; i < n ; i++)
{
if(strcmp(b[i].b_author,temp) == 0)
{
printf("\n%s\n",b[i].b_name);
}
}
break;
case 4 :
exit(0);
}
}while(ch != 4);
return 0;
}
Step by step
Solved in 2 steps