#include #include typedef struct _ListItem { struct _ListItem *prev; struct _ListItem *next; void *data; } ListItem; typedef struct { ListItem *top; ListItem *end; } ListHold; void list_add(ListHold *list, ListItem *item){ if(list->top == NULL) list->top = item; if(list->end != NULL) list->end->next = item; item->prev = list->end; list->end = item; } int main(){ ListHold list; ListItem *item; int i; int len; list.top = NULL; list.end = NULL; for(i = 1; i <= 3; i++){ item = calloc(1, sizeof(ListItem)); item->data = calloc(1, 10); len = sprintf(item->data, "data%d", i); list_add(&list, item); } for(item = list.top; item != NULL; item = item->next){ printf("%s\n", item->data); } }