#include #include /* ------------------------ List element definition ------------------------ */ struct ListElem { int value; struct ListElem* next; }; void printList( struct ListElem* h ) { while ( h != NULL ) { printf(" %d\n", h->value ); // Print h = h->next; // Go to next element in list } printf("\n"); } int main(int argc, char *argv[]) { struct ListElem* head; // Head of list struct ListElem* p; // Help variable to allocate new list element head = NULL; // Empty list /* ======================================================== Insert 123 ======================================================== */ p = malloc( sizeof(struct ListElem) ); p->value = 123; p->next = head; head = p; printList(head); /* ======================================================== Insert 444 ======================================================== */ p = malloc( sizeof(struct ListElem) ); p->value = 444; p->next = head; head = p; printList(head); /* ======================================================== Insert 789 ======================================================== */ p = malloc( sizeof(struct ListElem) ); p->value = 789; p->next = head; head = p; printList(head); }