-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
62 lines (57 loc) · 1.74 KB
/
main.c
File metadata and controls
62 lines (57 loc) · 1.74 KB
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
#include "product.h"
#define DEBUG
int main(void){
#ifdef DEBUG
printf("Debug: %s %s %s %d\n", __DATE__, __TIME__, __FILE__, __LINE__);
#endif
Product plist[100];
int index = 0;
int count = 0;
int snum; // selected number in Menu
count = loadData(plist);
index = count;
while(1){
snum = selectMenu();
if(snum == 0) break;
if(snum == 1 || snum ==3 || snum == 4)
if(count == 0) continue;
if(snum == 1) {listProduct(plist,count);}
else if(snum == 2){
// if(count>=1){
// printf("full !!\n");
// continue;
// }
count += addProduct(&plist[index++]);
}
else if(snum == 3){
int no = selectDataNo(plist, index);
if(no == 0){
printf("취소됨!\n");
continue;
}
int isupd = updateProduct(&plist[no-1]);
if(isupd == 1) printf("=> 수정성공!\n");
}
else if(snum == 4){
int no = selectDataNo(plist, count);
if (no == 0){
printf("=> 취소됨!\n");
continue;
}
int deleteok;
printf("정말로 삭제하시겠습니까?(삭제 :1) ");
scanf("%d",&deleteok);
if(deleteok == 1){
if(deleteProduct(&plist[no-1])) {
printf("=> 삭제됨!\n");
}
}
}
else if (snum == 5){saveData(plist,count);}
else if (snum == 6){searchName(plist,count);}
else if (snum == 7){searchPrice(plist,count);}
else if (snum == 8){searchWeight(plist,count);}
}
printf("종료됨!\n");
return 0;
}