소개글
연결리스트와 파일 입출력으로 이용해서 간단한 도서관리 프로그램을 작성txt파일이 임시 DB가 되어 도서목록이 저장
#include
#include
#include
#include
#include
// 책 정보를 표현한 구조체
typedef struct Book {
char genre[10]; // 책 장르
char title[30]; // 책 제목
char author[15]; // 저자
char rental_fee[10]; // 대여료
int exist; // 책 존재유무(유:1, 무:0)
int rental_term; // 대여기간
char rental_day[100]; // 대여날짜
char return_day[100]; // 반납해야할 날짜
struct Book *Genre; // 장르를 연결할 링크
struct Book *BookInfo; // 각 장르별 책을 연결할 링크
};
void main() {
int i, div = 0;
struct Book *ghead, *gtail; //장르를 연결할 연결리스트
struct Book *bookhead[5], *booktail[5]; // 장르별 책
struct Book *temp;
// 구조체 포인터에 메모리할당
ghead = (struct Book*)malloc(sizeof(struct Book));
gtail = ghead;
ghead->Genre = NULL;
for (i = 0; i < 5; i++) {
bookhead[i] = (struct Book*)malloc(sizeof(struct Book));
bookhead[i]->BookInfo = NULL;
bookhead[i]->Genre = NULL;
booktail[i] = bookhead[i];
}
// 장르별로 책을 묶음
for (i = 0; i< 5; i++) {
booktail[i] = Linked_Book(booktail[i], i);
}
// 장르를 생성하고 해당 장르의 책을 연결
for (i = 0; i < 5; i++)
gtail = Linked_Genre(gtail, bookhead[i], i);
while(1) {
system("cls");
switch(menu()) {
case 1: Display_Search(ghead); getch(); break; // 목록보기 & 검색
// 신간도서 입고
case 2: temp = Add_Book(booktail, &div); booktail[div] = temp; break;
// 도서 대여
case 3: Rental_Book(ghead); getch(); DB_Update(ghead); break;
// 도서 반납
case 4: Return_Book(ghead); getch(); DB_Update(ghead); break;
case 0: free(ghead); free(gtail); exit(0); break; // 종료하기
}
}
}
컴파일 실행환경
Microsoft Visual Studio 2010 (C++)압축파일 내 파일목록
BookManagement/BookManagement.sdf
BookManagement/BookManagement.sln
BookManagement/BookManagement.suo
BookManagement/BookManagement.vcxproj
BookManagement/BookManagement.vcxproj.filters
BookManagement/BookManagement.vcxproj.user
BookManagement/book_DB.txt
BookManagement/Debug/BookManagement.exe
BookManagement/Debug/BookManagement.exe.embed.manifest
BookManagement/Debug/BookManagement.exe.embed.manifest.res
BookManagement/Debug/BookManagement.exe.intermediate.manifest
BookManagement/Debug/BookManagement.exe.manifest
BookManagement/Debug/BookManagement.ilk
BookManagement/Debug/BookManagement.lastbuildstate
BookManagement/Debug/BookManagement.log
BookManagement/Debug/BookManagement.pdb
BookManagement/Debug/BookManagement.vcxprojResolveAssemblyReference.cache
BookManagement/Debug/BookManagement_manifest.rc
BookManagement/Debug/cl.command.1.tlog
BookManagement/Debug/CL.read.1.tlog
BookManagement/Debug/CL.write.1.tlog
BookManagement/Debug/link.1620.read.1.tlog
BookManagement/Debug/link.1620.write.1.tlog
BookManagement/Debug/link.3428.read.1.tlog
BookManagement/Debug/link.3428.write.1.tlog
BookManagement/Debug/link.5316.read.1.tlog
BookManagement/Debug/link.5316.write.1.tlog
BookManagement/Debug/link.command.1.tlog
BookManagement/Debug/link.read.1.tlog
BookManagement/Debug/link.write.1.tlog
BookManagement/Debug/Main.obj
BookManagement/Debug/mt.command.1.tlog
BookManagement/Debug/mt.read.1.tlog
BookManagement/Debug/mt.write.1.tlog
BookManagement/Debug/rc.command.1.tlog
BookManagement/Debug/rc.read.1.tlog
BookManagement/Debug/rc.write.1.tlog
BookManagement/Debug/vc100.idb
BookManagement/Debug/vc100.pdb
BookManagement/ipch/bookmanagement-78ae310d/bookmanagement-41641d54.ipch
BookManagement/Main.c
도서관리.hwp
BookManagement/BookManagement.sln
BookManagement/BookManagement.suo
BookManagement/BookManagement.vcxproj
BookManagement/BookManagement.vcxproj.filters
BookManagement/BookManagement.vcxproj.user
BookManagement/book_DB.txt
BookManagement/Debug/BookManagement.exe
BookManagement/Debug/BookManagement.exe.embed.manifest
BookManagement/Debug/BookManagement.exe.embed.manifest.res
BookManagement/Debug/BookManagement.exe.intermediate.manifest
BookManagement/Debug/BookManagement.exe.manifest
BookManagement/Debug/BookManagement.ilk
BookManagement/Debug/BookManagement.lastbuildstate
BookManagement/Debug/BookManagement.log
BookManagement/Debug/BookManagement.pdb
BookManagement/Debug/BookManagement.vcxprojResolveAssemblyReference.cache
BookManagement/Debug/BookManagement_manifest.rc
BookManagement/Debug/cl.command.1.tlog
BookManagement/Debug/CL.read.1.tlog
BookManagement/Debug/CL.write.1.tlog
BookManagement/Debug/link.1620.read.1.tlog
BookManagement/Debug/link.1620.write.1.tlog
BookManagement/Debug/link.3428.read.1.tlog
BookManagement/Debug/link.3428.write.1.tlog
BookManagement/Debug/link.5316.read.1.tlog
BookManagement/Debug/link.5316.write.1.tlog
BookManagement/Debug/link.command.1.tlog
BookManagement/Debug/link.read.1.tlog
BookManagement/Debug/link.write.1.tlog
BookManagement/Debug/Main.obj
BookManagement/Debug/mt.command.1.tlog
BookManagement/Debug/mt.read.1.tlog
BookManagement/Debug/mt.write.1.tlog
BookManagement/Debug/rc.command.1.tlog
BookManagement/Debug/rc.read.1.tlog
BookManagement/Debug/rc.write.1.tlog
BookManagement/Debug/vc100.idb
BookManagement/Debug/vc100.pdb
BookManagement/ipch/bookmanagement-78ae310d/bookmanagement-41641d54.ipch
BookManagement/Main.c
도서관리.hwp