السلام عليكم
تحيه للمبرمجين واتمنى منكم مساعدتي في هذا البرنامج
2. A data file contains information on all books checked out from a college library. Each record of the data file consists of the following fields:
1. Id number of borrowers (string)
2. Call number of book (string)
3. Name of author (structure)
4. Title of book (string)
5. Due date (mm/dd/yy) (string)
Write a program that declares a structure to store the information, reads the data for each book, and prints a list of all books checked out. Your program should include separate functions for reading and writing.
3. Update program 1 for it to be a menu driven program, display the following menu:
Electronic Library
1. Add a book
2. Search by author
3. Search by title
4. Search by due month
5. Quit
Enter your choice:
Add functions to perform each of the previous menu options.
وهذي محاولتي لكني توقفت عن عملية البحث في functions
#include<stdio.h>
#include<stdlib.h>
struct name{
char first[80];
char last[80];
};
typedef struct book{
char ID[80];
char number[80];
struct name author;
char title[80];
char date[80];
}book;
int addbook();
void author();
void title();
void duemonth();
void print(int);
int main()
{
int choice,exit=0,result;
book temp[80];
system("cls");
while(!exit){
printf("1 to add book\n");
printf("2 to search by author\n");
printf("3 to search by title\n");
printf("4 to search by due month\n");
printf("5 to print all books\n");
printf("6 quit\n");
scanf("%d",&choice);
system("cls");
switch(choice){
case 1:result=addbook(&temp);
break;
case 2:author(&temp->author);
break;
case 3:title(&temp);
break;
case 4:duemonth(&temp);
break;
case 5:print(&temp,result);
break;
case 6:exit=1;
break;
default:
printf("invlid choice, try again:\n");
scanf("%d",&choice);
}
}
return 0;
}
int addbook(book *add)
{
static int i=0;
char c;
scanf("%c",&c);
printf("enter ID of the book?\n");
scanf("%s",add->ID);
printf("enter number of the book?\n");
scanf("%s",add->number);
printf("enter the first name of book author's the th last name?\n");
scanf("%s%s",add->author.first,add->author.last);
printf("enter the title of the book?\n");
scanf("%s",add->title);
printf("enter due date(mm/dd/yy)?\n");
scanf("%s",add->date);
++i;
return i;
}
void author(struct name *author)
{
printf("enter the first name for the author?\n");
scanf("%s",author->first);
printf("enter the last name of the author?\n");
scanf("%s",author->last);
}
void title(book *title)
{
printf("enter the title of the book?\n");
scanf("%s",title->title);
}
void duemonth(book *due)
{
printf("enter the due month?\n");
scanf("%s",due->date);
}
void print(book *p,int r)
{
int i;
printf("%s%13s%10s%15s%20s\n","Title","Author","ID","Number","Due date");
for(i=0;i<r;i++)
printf("%s%5s%10s%15s%20s\n",*p->title,p->author,*p->ID,*p->number,*p->date);
}
رجاء خاص ليت كل من يعرف يساعدني
بليييييييييييييييييز
:(
