#include <stdio.h>
#include <stdlib.h>
struct Node {
int value;
struct Node* next;
};
struct Node* create_list(int number) {
int digit;
int rest_digits = number;
struct Node* head = 0;
struct Node* new = 0;
while (rest_digits) {
digit = rest_digits % 10;
rest_digits = rest_digits / 10;
new = malloc(sizeof(struct Node) * 1);
new->value = digit;
if (head == 0) new->next = 0;
else new->next = head;
head = new;
}
return head;
}
void print_list(struct Node* head) {
struct Node* node = head;
while (node) {
printf("[%d]-->", node->value);
node = node->next;
}
printf("XXX");
}
void destroy_list(struct Node* head) {
struct Node* node = head;
struct Node* next = 0;
while (node) {
next = node->next;
free(node);
node = next;
}
}
int main(void) {
struct Node* list;
list = create_list(123456789);
print_list(list);
destroy_list(list);
return 0;
}Answer:
The flowchart of the code:
Answer provided by AssignmentExpert.com