-
Notifications
You must be signed in to change notification settings - Fork 0
/
market.c
58 lines (52 loc) · 1.47 KB
/
market.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
#include <stdio.h>
#include <string.h>
#include "manager.h"
int main(void){
Product slist[100];
int curcount=0;
int count = 0, menu;
count = loadData(slist);
curcount=count;
while (1){
menu = selectMenu();
getchar();
if(menu == 0) break;
if(menu == 1 || menu ==3 || menu == 4){
if (count==0){
printf(" 데이터가 없습니다!\n");
continue;
}
}
if(menu == 1) listProduct(slist,curcount);
else if (menu == 2) {
count+=createProduct(&slist[curcount++]);
}
else if (menu == 3) {
int no=selectDataNo(slist, curcount);
if(no==0){
printf("=>취소됨!");
continue;
}
updateProduct(&slist[no-1]);
}
else if (menu == 4) {
int no=selectDataNo(slist, curcount);
if(no==0){
printf("=>취소됨!");
continue;
}
int deleteok;
printf("정말로 삭제하시겠습니까?(삭제:1)");
scanf("%d",&deleteok);
if(deleteok == 1){
if(deleteProduct(&slist[no-1])) count --;
}
}
else if (menu == 5){
if (count==0) printf("데이터가 없습니다!\n");
else saveData(slist,curcount);
}
}
printf("\n종료됨!\n");
return 0;
}