-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLinkedList.c
49 lines (36 loc) · 797 Bytes
/
LinkedList.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
void display(struct node *ptr)
{
while (ptr != NULL)
{
printf("%d\n", ptr->data);
ptr = ptr->next;
}
}
int main()
{
struct node *head;
struct node *first;
struct node *secound;
struct node *third;
head = (struct node *)malloc(sizeof(struct node));
first = (struct node *)malloc(sizeof(struct node));
secound = (struct node *)malloc(sizeof(struct node));
third = (struct node *)malloc(sizeof(struct node));
head->data = 45;
head->next = first;
first->data = 50;
first->next = secound;
secound->data = 60;
secound->next = third;
third->data = 80;
third->next = NULL;
display(head);
return 0;
}