Question: Complete the program by writing the missing code for list insert. 1 / * * same output as 1 1 - linked - list.c ,

Complete the program by writing the missing code for list insert.
1
/*
* same output as 11-linked-list.c, but
* uses list_insert(). note that list_insert()
* is called in reverse order
*/
#include
#include
#include
#define LEN 3// airport code len
struct node {
char code[LEN+1];
struct node *next;
};
void list_insert(char *s, struct node **start);
void list_print(struct node *p);
int main(void)
{
struct node *head = NULL;
list_insert("BKK", &head);
list_insert("PNH", &head);
list_insert("SGN", &head);
list_print(head);
return 0; }
/* insert node at beginning of list */
void list_insert(char *s, struct node **start)
{
// missing code goes here
}
void list_print(struct node *p)
{
while (p != NULL){
printf("%s
", p->code);
p = p->next;
}}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!