list = (struct Node *)malloc(sizeof(struct Node));list->number = 0;
list->next = NULL;
append_node(list, 1);
append_node(list, 5);append_node(list, 3);
display_list(list);
// delete a list here. free(list) will not work
return(0);
}
void delete_list(struct Node *list) {
// do it as your exercise
}
void display_list(struct Node *list) {
// loop over the list to print the value out.while(list->next != NULL) {
printf("%d ", list->number);
list = list->next;}
printf("%d", list->number);
}
void append_node(struct Node *list, int num) {
// go into the end of the list
while(list->next != NULL)
list = list->next;
// set the next property for the last Node object.
list->next = (struct Node *)malloc(sizeof(struct Node));
list->next->number = num;
list->next->next = NULL;
}