The following figure shows the basic structure of a single linked list:
The head pointer is the header of the list, pointing to the first node, the next pointer field for each node points to the next node, and the last node's next pointer field is NULL, shown in 0.
The following first look at the program (stack of the chain store implementation, another implementation point here) and the corresponding output (note that the output before the linked list inversion (see "Single linked list inversion", otherwise the program after the while loop output order is 250,200,100), followed by the analysis of the program:
* Linkedlist.h * *
#ifndef Linkedlist_h
#define Linkedlist_h
typedef struct node *link;
struct node
{
unsigned char item;
Link next;
};
Link make_node (unsigned char item);
void Free_node (link p);
Link search (unsigned char key);
void Insert (link p);
void Deletep (link p);
void Traverse (void (*visit) (link);
void reverse (void);
void Destroy (void);
void push (link p);
Link pop (void);
#endif