-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdel_begin
62 lines (56 loc) · 1003 Bytes
/
del_begin
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
//Linked list-----------beginning
#include<stdio.h>
#include<stdlib.h>
struct node{
int data;
struct node*next;
}*head=NULL;
void create(int n)
{
struct node *sec,*temp;
head=(struct node*)malloc(sizeof(struct node));
int d;
printf("enter data: ");
scanf("%d",&d);
head->data=d;
head->next=NULL;
temp=head;
for(int i=2;i<=n;i++){
sec=(struct node*)malloc(sizeof(struct node));
printf("enter data: ");
scanf("%d",&d);
sec->data=d;
sec->next=NULL;
temp->next=sec;
temp=sec;
}
}
void delete_begin()
{
// struct node* del;
// del=head;
// head=head->next;
// free(del);
struct node* del;
del=head;
head=head->next;
free(del);
}
void dis()
{
struct node *ptr;
ptr=head;
while (ptr != NULL)
{
printf("%d ", ptr->data);
ptr=ptr->next;
}
printf("\n");
}
int main()
{
create(5);
dis();
delete_begin();
dis();
}