Creating and Initializing a List


To create an empty linked list, you first create a variable of type List. You then initialize the list, which gives the list a name and initializes its head and tail anchors, by calling the InitList() function:

void InitList( List *l, const char *name )
The l argument is a pointer to the list to be initialized. The name argument is the name of the list.

Another way to initialize a list is by using the INITLIST() macro. This macro lets you define a fully initialized List as a variable. By using the macro, you avoid the need to call the InitList() function. Here is an example of using the INITLIST macro to create a variable called listOfStuff:

static List listOfStuff = INITLIST(listOfStuff,"List Name");