forked from KimGyeongLock/Lab13
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
67 lines (64 loc) · 1.7 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "book.h"
int main(void){
Book b[100];
int count = 0, menu = 0;
int curcount = 0;
count = loadBookList(b);
curcount = count;
while (1){
menu = selectMenu();
if (menu == 0) break;
if (menu == 1 || menu == 3 || menu == 4){
if(count == 0) {
printf("조회할 목록이 없습니다!\n");
continue;
}
}
if (menu == 1){
if(count > 0){
listBook(b,curcount);
}
}
if (menu == 2){
count += addBook(&b[curcount++]);
}
else if (menu == 3){
int no = selectBookNum(b, curcount);
if(no == 0){
printf("취소되었습니다.");
continue;
}
updateBook(&b[no-1]);
}
else if (menu == 4){
int no, deleteok;
no = selectBookNum(b, curcount);
if(no==0){
printf("취소되었습니다.\n");
continue;
}
printf("이 책을 대출하시겠습니까?(예:1) ");
scanf("%d", &deleteok);
if(deleteok == 1){
deleteBook(&b[no-1]);
count--;
}
}
else if (menu == 5){
if(count ==0){
printf("데이터가 없습니다.\n");
}
else{
saveBookList(b, curcount);
}
}
else if(menu == 6){
if(count == 0)
printf("데이터가 없습니다.\n");
else
searchBookName(b, curcount);
}
}
printf("종료됨!\n");
return 0;
}