Code: Select all
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 #define storage 5
6 struct human ary[storage];
7
8 typedef struct{
9 double weight[20];
10 double height[20];
11 }human;
12
13 //int window();
14 void window_operate();
15 void BMI();
16 void calorie();
17 void food_calender();
18
19 int main(void)
20 {
21 char *ID;
22 char *PW;
23 char *in_PW="1234567";
24 char *in_ID="201720963";
25 ID = (char*)malloc(sizeof(char) *11);
26 PW = (char*)malloc(sizeof(char) *11);
27
28 while(1)
29 {
30 printf("input your ID: ");
31 scanf("%s", ID);
32
33 if(ID != "201720963")
34 {
35 printf("ID error \n");
36 continue;
37 }
38 else
39 break;
40 }
41 while(1)
42 {
43 printf("input your PW: ");
44 scanf("%s", PW);
45
46 if(PW != "1234567")
47 {
48 printf("PW error \n");
49 }
50 else
51 {
52 printf("successfully login \n");
53 break;
54 }
55 }
56 free(ID);
57 free(PW);
58 // window();
59 window_operate();
60 BMI();
61 calorie();
62 food_calender();
63
64 return 0;
65 }
66 void window_operate()
67 {
68 int token = 0;
69 printf("-------------------------------------------------------- \n\n");
70 printf("------------- Health inprovement management ------------ \n");
71 printf("1. BMI_measurement 2.calorie_measurement 3.food_calender 0.exit\ n");
72 printf("select_your_number: ");
73 scanf("%d", &token);
74 printf("-------------------------------------------------------- \n\n");
75
76 switch(token)
77 {
78 case 0: exit(1);
79 case 1: BMI();
80 case 2: calorie();
81 case 3: food_calender();
82 default: printf("wrong input \n");
83
84 }
85 }
85 void BMI()
86 {
87 int i;
88 double bmi = 0;
89
90 for(i=0; i<storage; i++)
91 {
92 printf("ex) 84.3 175.2 \n");
93 printf("input your weight height: ");
94 scanf("%lf %lf", &ary[i].weight, &ary[i].height);
95 bmi = ary[i].weight / (ary[i].height * ary[i].height)*10000;
96 printf("%8.1f %8.1f %8.1f \n", ary[i].weight, ary[i].height, bmi);
97 if(bmi>30)
98 printf("obesity \n");
99 else if(bmi >= 25)
100 printf("overweight \n");
101 else if(bmi >= 19)
102 printf("normal \n");
103 else
104 printf("underweight \n");
105 }
106}
107 void calorie()
108 {
109 int i;
110 int gender = 0;
111 int age = 0;
112 int result = 0;
113
114 printf("male calorie average:2500 \n");
115 printf("female calorie average:2000 \n");
116 printf("male input 1 female input 2 and input age \n");
117 scanf("%d %d",&gender, &age);
118
119 for(i = 0; i<storage; i++)
120 {
121 if(gender == 1)
122 {
123 result = 88 + (13 * ary[i].weight + 4 * ary[i].height) - (5 * age);
124 }
125 else if(gender == 2)
126 {
127 result = 44 + (9 * ary[i].weight + 3 * ary[i].height) - (4 * age);
128 }
129 }
130 printf("your basic metabolic capacity: %d \n",result);
131 }
struct human ary[storage];
이러한 오류는 어떻게 해결해야 하나요? 구조체는 저렇게 선언할수 없는건가요?