여기 해더파일(1)과 (2)를 합칠 수 있는지 궁금하고요, 미작성된부분(1)(2)(3) 좀 돠주세요
한국드립
/* 도서 정리 프로그램 */
#include stdio.h
#include book.h
int getuser command();
void getbookinformation(book *p, int n, int index); // 저자이름과 같은 걸 찾는 함수.
void showbookwithauthormain(book *p, int n);
#define max_number 100
int main(int argc, char* argv[])
{
book books[max_number];
int cmd, index=0;
while(1)
{ cmd = getusercommand();
switch(cmd)
{
case 1:
getbookinfomain(books, max_number, index);
index++;
break;
case 2:
showbookwithauthor(books, index);
break;
case 3:
showbookwithtitlwmain(books, index);
break;
}
if(cmd == 4) break;
}
return 0;
}
int getusercammand()
{
int cmd
while(1)
{
printf(\t1. 도서 입력\n wt2. 저자별 검색\n\t3. 제목 검색\n\t4. 끝);
printf(명령 : );
sacanf(%d, &cmd);
if (cmd 1 \ cmd 4){
printf(없는 메뉴입니다. 다시 선택하시오.\n);
continue;
}
break;
}
fflush(stdin);
return 0;
}
void getbookinfomain(book *p, int n, int index)
{
p[index] = getbookinfo();
showbookinfo(&p[index]);
}
void showbookwithauthor(book *p, int n);
{
/*미작성 된부분(1)*/
}
void showbookwithtitlemain(book *p, int n)
{
/*미작성 된부분(2)*/
}
/*여기는 해더파일 입니다(1)*/
#ifndef
#define book_h
type struc book_tag
{
char title[200]
char author[40]
char publisher[20]
int year, month, day, price;
}
book;
book getbookinfo();
void showbookinfo(book *pbook);
void showbookinfos(book *pbook, int n, char author[]);
void showbookwithtitle(book *pbook, int n, char title[]);
#endif
/*여기는 해더파일 입니다(2)*/
#include stdio.h
#include string.h
#include book.h
book getbookinfo()
{
book book;
printf(새 책 정보 입력 ==========\n);
printf(제목 : ); gets(book, title);
printf(저자 : ); gets(book, author);
printf(출판사 : ); gets(book, publisher);
printf(출판일 : );
scanf(%d %d %d, &book.year, &book.month, &book.day);
printf(가격 : );
scan(%d, book.price);
return book;
}
void showbookinfo(book *pbook)
{
printf(------------------------------------------\n);
printf(제목 : %s\n, pbook-title);
printf(저자 : %s\n, pbook-author);
printf(출판사 : %s\n, pbook-publisher);
printf(출판일 : %4d년 %d월 %d일\n, pbook-year, pbook-month, pbook-day);
printf(가격 : %d\n, pbook-price);
}
void showbookinfos(book *book, int n)
{
/*미작성된부분(3)*/
}
void showbookwithauthor(book *pbook, int n, char author[])
{
int i;
for( i=0, in, i++)
{
if(!strcmp(pbook[i].author, author))
{
showbookinfo(&pbook[i]);
}
}
}
void showbookwithtitle(book *pbool, int n, char title)
{
int i;
for( i=0, in, i++)
{
if(!strcmp(pbook[i].title, title))
{
showbookinfo(&pbook[i])
}
}
}