how to create a linked list code example
Example 1: how to make a linked list in c
typedef struct node{
int value;
struct node *next;
}node;
node *createNode(int val){
node *newNode = malloc(sizeof(node));
newNode->value = val;
newNode->next = NULL;
return newNode;
}
Example 2: doubly linked list example
void insertFirst(int key, int data) {
struct node *link = (struct node*) malloc(sizeof(struct node));
link->key = key;
link->data = data;
if(isEmpty()) {
last = link;
} else {
head->prev = link;
}
link->next = head;
head = link;
}