Keeping Linked List Information

The head node

When working with lists, there seem to be certain items of information about the list that is common. Some of these things are: It is quite common to have another type of struct that holds this information about the list. It can increase efficiency in the program by always keeping a total of some data members, etc.

Here's an example:

typedef struct node *NODEPTR; typedef struct node { int data; NODEPTR next; }NODE; /* Struct to keep info about the list */ typedef struct listInfo { int numNodes; int dataTotal; NODEPTR head; NODEPTR tail; } LISTINFO;