fault.c (Appendix 1) 1 #include 2 #include 3 4 struct List { 5 int elem; 6 struct List *next; 7 }; 8 9 struct List addElement (int element, struct List *list) { 10 struct List *head; 11 12 head = malloc (sizeof (struct List)); 13 if (head = NULL) { 14 fprintf (stderr, "Not enough memory!\n"); 15 exit (1); 16 } 17 head->element = element; 18 head->next = list; 19 return head; 20 } 21 22 23 int main (int argc, char** argv) { 24 25 int i = 0; 26 27 struct List *list = NULL; 28 argc--; 29 i++; 30 while (argc > 0) { 31 list = addElement (list, argv[i]); 32 argc--; 33 i++; 34 } 35 36 while (list) { 37 printf ("The next list element is %d\n", list->element); 38 list = list.next; 39 } 40 exit (0); 41 }