-
Notifications
You must be signed in to change notification settings - Fork 0
/
datst.c
41 lines (34 loc) · 792 Bytes
/
datst.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
#include<stdio.h>
#include<stdlib.h>
struct node
{
int data;
struct node *link;
};
void main()
{
struct node *head;
head=(struct node*)malloc(sizeof(struct node*));
head->data=10;
head->link=NULL;
printf("First node");
printf("\n%d",head->data);
printf("\n%d",head->link);
struct node *current;
current=(struct node*)malloc(sizeof(struct node*));
current->data=20;
current->link=NULL;
head->link=current;
printf("\n%d",head->link);
printf("\nSecond node");
printf("\n%d",head->link->data);
printf("\n%d",head->link->link);
current=(struct node*)malloc(sizeof(struct node*));
current->data=30;
current->link=NULL;
head->link=current;
printf("\n%d",head->link);
printf("\nThird node");
printf("\n%d",head->link->data);
printf("\n%d",head->link->link);
}