-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathd2_linked_list.c
More file actions
47 lines (35 loc) · 774 Bytes
/
d2_linked_list.c
File metadata and controls
47 lines (35 loc) · 774 Bytes
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
// Linked List
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node* next;
};
void printList(struct node *n);
int main(void)
{
struct node* head = NULL;
struct node* second = NULL;
struct node* third = NULL;
head = (struct node*)malloc(sizeof(struct node));
second = (struct node*)malloc(sizeof(struct node));
third = (struct node*)malloc(sizeof(struct node));
// Assign Data to Node
head->data = 65735;
head->next = second;
second->data = head->data+1;
second->next = third;
third->data = second->data+1;
third->next = NULL;
printList(head);
return 0;
}
void printList(struct node *n)
{
while(n != NULL)
{
printf("%d ",n->data);
n = n->next;
}
}