-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLinkedList.c
More file actions
89 lines (74 loc) · 1.34 KB
/
Copy pathLinkedList.c
File metadata and controls
89 lines (74 loc) · 1.34 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include<stdio.h>
#include<conio.h>
#include<string.h>
void Insert(int data);
void Print();
void Delete(int data);
//Declaring a Node
struct Node{
int data;
struct Node* link;
};
//Global Variables
struct Node* head;
int main(){
head=NULL;
int ch;//choose
Insert(23);
Insert(19);
Insert(207);
Insert(407);
Insert(890);
Print();
/*while (1){
printf("1.Insert Node\n2.Delete Node\n3.Exit\n: ");
scanf("%d",&ch);
switch (ch){
case 1:
printf("Insert a data: ");
scanf("%d",&data);
Insert(data);
break;
case 2:
printf("Delete a data: ");
scanf("%d",&data);
Delete(data);
break;
case 3:
exit(0);
break;
}//end of switch case
system("cls");
}//end of while
*/
}//end of main
void Insert(int data){
struct Node* newNode = (struct Node*)malloc(sizeof (struct Node));//making a new node
if (head==NULL){
newNode->data = data;
newNode->link = NULL;
head = newNode;
}else {
newNode->data=data;
newNode->link=head;
head=newNode;
}
}//end of insert
void Print(){
int x;
struct Node* traversal = head;
printf("Address | Link | Data\n");
for (x=0;x<25;x++){
printf("_");
}
while (traversal!=NULL){
if (traversal->link==NULL){
printf("\n%p | NULL | %d",traversal,traversal->data);
break;
}
printf("\n%p | %p | %d ",traversal,traversal->link,traversal->data);
traversal = traversal->link;
}
}//end of print
void Delete(int data){
}//end of delete