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, 21.06.2019 21:00
Select all that apply. what types of documents can be created using word-processing software? business newsletters letters of application presentation slideshows customer databases
Answers: 1
question
Computers and Technology, 21.06.2019 21:30
Asuccessful format string attack attempted to steal user account information by reading from unauthorized memory. answer the followings with proper explanation a)this attack will lead to violation of which security policies?
Answers: 2
question
Computers and Technology, 22.06.2019 17:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print
Answers: 3
question
Computers and Technology, 23.06.2019 02:30
Research data that is presented using descriptive language is said to be
Answers: 2
You know the right answer?
Please write this in C. Regarding the following linked lists:
typedef struct _orderList
Questions
question
Mathematics, 16.07.2021 18:40
Questions on the website: 13722367