-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathUnlimited_link_list.c
63 lines (59 loc) · 1.26 KB
/
Unlimited_link_list.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <stdio.h>
#include <stdlib.h>
struct node
{
int data;
struct node *next;
};
struct node * createlist()
{
int user;
struct node *head = NULL;
struct node *p = NULL;
struct node *newnode = NULL;
while (1)
{
label:
newnode = (struct node *)malloc(sizeof(struct node));
printf("Enter data : ");
scanf("%d", &newnode->data);
newnode->next = NULL;
if (head == NULL)
{
head = newnode;
}
else
{
p = head;
while (p->next != NULL)
{
p = p->next;
}
p->next = newnode;
}
printf("Do you want to continue?(1/0) : ");
scanf("%d",&user);
if (user==0)
{
break;
}
}
return head;
}
void display(struct node * head){
struct node*p1=head;
while (p1!=NULL)
{
printf("%d->",p1->data);
p1=p1->next;
}
printf("NULL");
}
int main()
{
struct node *head = NULL;
head = createlist();
printf("The linklist is : ");
display(head);
return 0;
}