A linked list is a common data structure in which each node is linked by a chain or pointer, and the program accesses the nodes in the linked list through an indirect pointer.
typedef struct NODE { //pointer to the next node struct node *next; int value; }
Single-linked lists can be traversed only one way
Insert in single-linked list: first edition
#include <stdio.h> #include <stdlib.h> #define TRUE 1#define FALSE 0typedef struct Node {struct node *next;int V Alue;} linklist;//assumes the list from small to large sort int Linkinsert (linklist * Current, int value) {//Save the previous node linklist *previous; Linklist *new;//Loop to the appropriate position while (current-> value < value) {previous = Current;current = Current->next;} New = malloc (sizeof (linklist)); if (new = = NULL) {return FALSE;} New->value = Value;new->next = Current;previous->next = New;return TRUE;}
C and Pointers the 12th chapter uses structures and pointers