Linked List Introduction
Linked List Introduction
Why malloc():
● No need to initially occupy a large amount of memory.
● Memory can be allocated as well as de-allocated as per necessity.
● It avoids the memory shortage as well as memory wastage.
● In the Linked List, data is stored in the form of nodes and at runtime
memory is
allocated for creating nodes using malloc() function.
struct node{
int data;
struct node *next;
};
#include <stdio.h>
#include <stdlib.h>
int main() {
Node* head = NULL;
return 0;
}
#include <stdio.h>
#include <stdlib.h>
int main() {
Node* head = NULL;
return 0;
}