subject

Please write this in C. Regarding the following linked lists:
typedef struct _orderList
{
foodNode *head; // Pointer to first food item for the order (alphabetical)
int count; // Number of food items in the order
} orderList;
Where foodNode is defined as
typedef struct _foodNode
{
char *data; // Food Item Name
struct _foodNode *next;
} foodNode;
You will provide the following functions to operate on orderLists:
orderList *createItem(). Creates (using dmalloc() -- see below) an instance of an orderList struct, initializes its fields and returns a pointer to the newly allocated struct.
int insert(char *str, orderList *s). Places a new string in the orderList by inserting a new foodNode into its linked list and increments count. The food items will be inserted into the orderList in alphabetical order (use strcmpi() below for this). Duplicate strings (ignoring case) will not be allowed in the orderList. Returns 0 if the insertion was successful, and 1 otherwise.
void printItems(orderList *s). Displays the elements of the orderList with each string on a new line.
You may find the following two functions useful:
/* compares strings for alphabetical ordering */
int strcmpi(char *s, char *t)
{
while (*s && tolower(*s) == tolower(*t))
{
s++;
t++;
}
return tolower(*s) - tolower(*t);
}
/* allocates memory with a check for successful allocation */
void *dmalloc(size_t size)
{
void *p = malloc(size);
if (!p)
{
printf("memory allocation failed\n");
exit(1);
}
return p;
}
Always check the pointer returned by malloc() for successful memory allocation. You may use the dmalloc() function above in place of malloc() to ensure that this is always done. You may also find it convenient to write a function char *stringcopy(char *s) which creates (with dmalloc()) a copy of the string parameter.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 23.06.2019 12:10
2. fabulously fit offers memberships for$35 per month plus a $50 enrollmentfee. the fitness studio offersmemberships for $40 per month plus a$35 enrollment fee. in how many monthswill the fitness clubs cost the same? what will the cost be?
Answers: 1
question
Computers and Technology, 24.06.2019 18:30
Is a type of bullying that takes place when a person intentionally posts negative information about another person that is not true.
Answers: 2
question
Computers and Technology, 24.06.2019 23:30
Adrian has decided to subscribe for a new internet connection. he wants a high speed connection so that he can stream video content smoothly. which access technology would you advise adrian against using?
Answers: 1
You know the right answer?
Please write this in C. Regarding the following linked lists:
typedef struct _orderList
Questions
question
Chemistry, 13.04.2020 20:38
question
Mathematics, 13.04.2020 20:38
Questions on the website: 13722367