Question: Modify the program so that it adds each new node at the end of the list. #include #include #include struct Node { char *data; struct
Modify the program so that it adds each new node at the end of the list.
#include
while (fgets(buf, sizeof(buf), infile)) // create list { p = (struct Node *)malloc(sizeof(struct Node)); p->data = strdup(buf); p-> next = head; head = p; }
p = head; // traverse list while (p) { printf("%s", p->data); p = p->next; } }
xt; } }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
