#include #include struct List { int value; struct List *next; }; typedef struct List list; /* ----------------------------------------- Print list ----------------------------------------- */ void print( list *h ) { struct List *ptr; ptr = h; printf("List>> "); while ( ptr != NULL ) { printf("%d ", ptr->value ); ptr = ptr->next; } printf("\n"); } /* ----------------------------------------- Insert at head ----------------------------------------- */ void insert( struct List *h, struct List * p) { p->next = h; h = p; } int main(int argc, char *argv[ ]) { struct List *head = NULL; print( head ); struct List * p; p = malloc( sizeof( struct List) ); p->value = 4; insert(head, p); print( head ); p = malloc( sizeof( struct List) ); p->value = 8; insert(&head, p); print( head ); }