forked from CodeMaster17/DSA-Tutorials---CWH
-
Notifications
You must be signed in to change notification settings - Fork 0
/
07_LinkedListPRactice.c
46 lines (39 loc) · 1 KB
/
07_LinkedListPRactice.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
//HARSSHIT YADAV
//2105891
//Creating a linked list on my own
#include<stdio.h>
#include<stdlib.h>
// creating the structure for linked list
struct Harshit{
int num;
struct Harshit *pointer;
};
void printingValues(struct Harshit *points){
while(points != NULL)
{
printf("Elements is:%d \n", points->num);
points = points->pointer;
}
}
int main()
{
struct Harshit *first;
struct Harshit *second;
struct Harshit *third;
// allocating memory to the memory locaations
first = (struct Harshit *)malloc(sizeof(struct Harshit));
second = (struct Harshit *)malloc(sizeof(struct Harshit));
third = (struct Harshit *)malloc(sizeof(struct Harshit));
// allocating memory to the locations
// first to second
first->num = 990;
first->pointer = second;
// second to third
second->num = 239884;
second->pointer = third;
// third to fourth
third->num = 92132190;
third->pointer = NULL;
printingValues(first);
return 0;
}