Question: This code is not compiling please fix it. The code is too long so it can't be posted and I am getting error in line
This code is not compiling please fix it.
The code is too long so it can't be posted and I am getting error in line 88 and 127.
1 2 3 #include #include #include 4 5 6 #define DAYS 31 #define DEST 3 #define BUFF 100 7 8 9 10 11 12 13 14 15 16 17 18 19 struct node { char group_leader(BUFF]; int cnt; struct node *next; }; typedef struct node node; node*list[DAYS + 1][DEST + 1]; int use[DAYS + 1][DEST + 1]; int sz[DAYS + 1][DEST + 1]; 20 char dest_name[DEST+1][BUFF]; 21 22 23 24 char S[BUFF]; 25 26 27 28 29 30 31 void print_des(char *s) { int dest = s[2] - 'o'; S- printf("%s: %s ",s,dest_name[ dest]); for (int day = 1; day group_leader); head = head->next; 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 printf(" "); } printf("---- } void delete_group(char *s) { for (int dest 1; dest group_leader)) 66 { if (prev NULL) { 67 68 69 70 71 72 73 74 list[day][dest] = head->next; ] sz[day][dest] -- head->cnt; return; } prev->next = head->next; sz[day][dest) -= head->cnt; return; 75 76 77 78 prev - head; head - head->next; printf("%s could not be found ", s); exit(EXIT_FAILURE); 80 81 82 83 84 85 86 87 88 89 90 91 92 93 void har_add(int dest, int date, int cnt, int mx, char *s) { if (date DAYS dest DEST Cnt Il m) printf("error in reading values "); exit(EXIT_FAILURE); } 94 95 96 97 node *head = (node *)malloc(sizeof(node)); head->next = list[date][dest); strcpy(head->group_leader, s); head->cnt = cnt; sz[date] (dest] += cnt; use[date][dest] = 1; list[date][dest] - head; 98 while (sz[date][dest] > mx) { node *head = list[date][dest); node *prev = NULL; 99 100 101 102 103 104 105 106 107 108 109 110 111 while (head = NULL) if (head->next -- NULL) if (prey -- NULL) list[date] [dest] = NULL; sz[date] [dest] head->cnt; break; 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 prev->next = NULL; sz[date][dest] head->cnt; break; } head; head = head->next; prev = } } void add(int dest, int date, int cnt, int mx, char *s) { if (date DAYS dest DESTcnt mx) return; node *last = (node *)malloc(sizeof(node)); last->next = NULL; strcpy(last->group_leader, s); last->cnt = cnt; sz[date][dest] += cnt; 138 139 140 141 node *head list[date][dest]; 142 143 144 145 146 if (head NULL) last; list[date][dest] return; 147 return; while (head (= NULL) { if (head->next == NULL) { head->next = last; break; } head = head->next; } } int main() { 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 strcpy(dest_name[1], "Darjeeling"); strcpy(dest_name[2], "Leh"); strcpy(dest_name[3], "ooty"); FILE *fptr; // Open file fptr = fopen("input.txt", "r"); if (fptr == NULL) { printf("Cannot open file "); exit(); int mxn = 0; fscanf(fptr, "%d", &mxn); int dest -1; int date -1; int cnt = -1; while (1) C programming { fscanf(fptr, "%s", s); if (Istrcmp(s, "C9")) { break; } if (Istrcmp(s, "c8")) { fscanf(fptr, "%s", s); print_des(s); continue; } if (Istrcmp(s, "C5")) { NO fscanf(fptr, "%s", s); delete_group(s); continue; 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 } if (Istrcmp(s, "C3A")) { / fscanf(fptr, "%s", s); fscanf(fptr,"%d", &cnt); har_add(dest, date, cnt, mxn, s); continue; } if (Istrcmp(s, "c3")) { fscanf(fptr, "%s", s); fscanf(fptr, "%d", &cnt); add(dest, date, cnt, mxn, s); continue; if (Istrcmp(s, "c2")) { fscanf(fptr, "%d", &date); continue; if (Istrcmp(s, "C1")) { fscanf(fptr,"%s", s); dest=s[2]-'@'; continue; 220 221 222 223 224 225 226 227 228 229 230 231 232 233 printf("invalid command "); exit(EXIT_FAILURE); fclose(fptr); return; }