#include #include /* * * author: Jacques Carette ITB 168 * */ typedef struct ll_struct { int data; struct ll_struct *next; } ll_struct; typedef ll_struct *ll; #define ll_NULL (ll)NULL void Show(ll link_list); void Add_memory(ll curr_node); void Insert(ll curr_node, int data); int main(void) { ll root = ll_NULL; Show(root); return 0; } void Show(ll link_list) { if (link_list != ll_NULL) { printf("%d ", link_list->data); Show(link_list->next); } } void Add_memory(ll curr_node) { ll tmp; if (curr_node == NULL) { printf("current node is NULL"); exit(1); } tmp = (ll)malloc(sizeof(ll_struct)); if (tmp == ll_NULL) { printf("out of memory"); exit(1); } curr_node->next = tmp; } void Insert(ll curr_node, int data) { if (curr_node->next == ll_NULL) { Add_memory(curr_node); curr_node->next->data = data; } }