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 01:30
How will you cite information that is common knowledge in your research paper?
Answers: 1
question
Computers and Technology, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
question
Computers and Technology, 23.06.2019 07:30
What is the original authority for copyright laws
Answers: 1
question
Computers and Technology, 24.06.2019 13:30
In the rgb model, which color is formed by combining the constituent colors? a) black b) brown c) yellow d) white e) blue
Answers: 1
You know the right answer?
Please write this in C. Regarding the following linked lists:
typedef struct _orderList
Questions
Questions on the website: 13722361