#include "slist.h" #include <stdio.h> #include <stdlib.h> #include <string.h> static SList * add_data (SList *list) { char buffer[128]; printf ("Input the data "); scanf ("%s", buffer); char *str = strdup (buffer); return slist_prepend (list, str); } static void print_data (SList *list) { SList *l; for (l = list; l != NULL; l = l->next) { printf ("%s\n", (char *) l->data); } } int main (void) { SList *list = NULL; while (1) { list = add_data (list); print_data (list); } slist_free_all (list, free); return 0; }