From 57624a5557562aff2ab3d545cf2fcf90a879674d Mon Sep 17 00:00:00 2001 From: anjali9811 <72162196+anjali9811@users.noreply.github.com> Date: Thu, 1 Oct 2020 02:04:50 +0530 Subject: [PATCH] Create structure of linked list Each struct node has a data item and a pointer to another struct node. --- structure of linked list | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 structure of linked list diff --git a/structure of linked list b/structure of linked list new file mode 100644 index 0000000..fa25f84 --- /dev/null +++ b/structure of linked list @@ -0,0 +1,23 @@ +/* Initialize nodes */ +struct node *head; +struct node *one = NULL; +struct node *two = NULL; +struct node *three = NULL; + +/* Allocate memory */ +one = malloc(sizeof(struct node)); +two = malloc(sizeof(struct node)); +three = malloc(sizeof(struct node)); + +/* Assign data values */ +one->data = 1; +two->data = 2; +three->data=3; + +/* Connect nodes */ +one->next = two; +two->next = three; +three->next = NULL; + +/* Save address of first node in head */ +head = one;