Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXBINS 99 #d

ID: 3841131 • Letter: #

Question

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
                          
#define MAXBINS 99
#define MAXCORS 26
#define MAXCUS 100
#define MAXPUR 10


/* datatype for a list of orders ----------------- */

typedef struct {
int bin_order_number;
char bin_order_char;
}bin_order;
typedef struct {
int orderNo;
bin_order orderbin;
}order;
typedef struct {
int cusnumber;
int n;   /* number of the orders what the txt include */
order oo[MAXPUR+1];
}customer;
typedef struct{
int n; /*number of the customers */
customer cc[MAXCUS+1];
}orderlist_t;


int creatorderlist(orderlist_t *orderlist);
void printorderlist(orderlist_t *orderlist, char *title);

int
main(int argc, char *argv[]) {
orderlist_t theorder;
/*for stage 1*/
/* 1 ---------- creates the order list theorder */
creatorderlist(&theorder);
/* 2 ---------- print the order list theorder */
printorderlist(&theorder,"STAGE 1");
/*for stage 2*/
return 0;
}

int
creatorderlist(orderlist_t *orderlist){
int i,p;
int total_items=0;
for(i=0;
  i<MAXCUS && scanf("%d %d",
   &(orderlist->cc[i].cusnumber),
   &(orderlist->cc[i].n))==2;
   i++){
  total_items=total_items+orderlist->cc[i].n;
  for (p=0;p<oderlist->cc[i].n && scanf("%d %d%s",
   &(orderlist->cc[i].oo[p].orderNo),
   &(orderlist->cc[i].oo[p].orderbin.bin_order_number),
   &(orderlist->cc[i].oo[p].orderbin.bin_order_char))==3;
   p++){
  }
}
orderlist->n=i;
return total_items;
}
   


void
printorderlist(orderlist_t *orderlist,char *title){
int i,p;
/*firstly,print the tile and the header lines */
printf("%s ",title);
printf("_______ ");
printf(" orders: %d ",orderlist->n);
printf(" items : %d ",creatorderlist(orderlist_t *orderlist));
/* then, print the order of each customer one by one*/
for(i=0;i<orderlist->n;i++){
  printf("   customer %d, %d items, bins:",orderlist->cc[i].cusnumber,orderlist->cc[i].n);
  for(p=0;p<creatorderlist(orderlist_t *orderlist);p++){
   printf(" %d%s ",orderlist_t->cs[i].oo[p].orderbin.bin_order_number,
       orderlist_t->cc[i].oo[p].orderbin.bin_order_char);
  }
}
printf(" ");
}

C: Users Alienware gcc -Wall -o ass2 ass2. c ass2.c: In function creatorderlist ass2. c:57:14: error oderlist" undeclared (first use in this function) for p 0 p oderlist->cc li n && scanf %d 9%d%s ass2. c:57:14: note: each undeclared identifier is reported only once for each function it appears in ass2. C In function printorderlist' ass2. c:77:42: error: expected expression before orderlist t printf items %d creatorderlist (orderlist t*orderlist ass2. 81 28: error: expected expression before orderlist t for (p 0:p creat orderlist (orderlist t *order list) p++ ass2. c:82:20: error: expected expression before orderlist t printf %d%s order list t- cs il. oo [pl orderb in. bin order number

Explanation / Answer

ERROR1: ass2.c:57:14 Spelling mistake: 'oderlist' ==> 'orderlist'

ERROR2: ass2.c:77:42: Syntax error: creatorderlist(orderlist_t *orderlist) ==> creatorderlist(*orderlist)

ERROR3: ass2.c:81:28: Syntax error: creatorderlist(orderlist_t *orderlist) ==> creatorderlist(*orderlist)

ERROR4: ass2.c:82:20: Spelling mistake(use object not struct):

orderlist_t->cs[i].oo[p].orderbin.bin_order_number ==>

orderlist->cs[i].oo[p].orderbin.bin_order_number

DO THUMBS UP ^_^