CS 211 - 2/3/17 Linked List First we create a structure that will contain both data and a pointer/reference to the next item in the list. In CS 211, I will focus on singularly linked list. struct linkedStruct { int data; struct linkedStruct* next; }; typedef struct linkedStruct linked; typedef struct linkedStruct* linkedPtr; /* variable for the beginning of the list */ linked* head; linkedPtr hd2; int value; /* make the list empty */ head = NULL; /* NULL is defined in stdlib.h */ hd2 = NULL: addToFront ( &head, 15); addAtFront ( &head, 7); while ( isEmpty(head) == FALSE ) { printf ("%d\n", getFront(head) ); removeFirstValue (&head); } function1 ( &value ); /* function to add a node to the beginning of the list */ void addToFront (linked** hd, int val) { linked* temp; temp = (linked*) malloc (sizeof (linked) ); temp->data = val; temp->next = *hd; *hd = temp; } int getFront (linked* hdpbv) { return (hdpbv->data); } int isEmpty (linked* hdpbv) { if (hdpbv == NULL ) return TRUE; else return FALSE; } void removeFirstValue (linked** hd) { linked* temp = *hd; /* verify that the list is not already empty */ if ( isEmpty ( temp ) == FALSE ) { *hd = temp->next; free (temp); } } } } /* alternative forms */ void addToFront2 (linkedPtr* hd2, void function1 (int* val)