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
| int main (int argc, const char * argv[])
{
list_pointer first,second;
first = create_node(100);
second = create_node(20);
first->link = second;
second->link = NULL;
printf("The list with first and second node \n");
print_list(first);
printf("The list with empty ptr,insert node(50) \n");
list_pointer new_node1 = create_node(50);
insert(&ptr, ptr, new_node1);
print_list(ptr);
printf("The list with ptr \n");
ptr = (list_pointer) malloc(sizeof(list_node));
ptr->link=first;
ptr->data=1024;
print_list(ptr);
printf("\n Insert \n");
printf("The list with ptr,insert node(50) after first node \n");
list_pointer new_node2 = create_node(50);
insert(&ptr, first, new_node2);
print_list(ptr);
printf("\n Delete \n");
printf("The list with ptr,delete first node\n");
delete(&ptr, ptr,first);
print_list(ptr);
printf("The list with ptr,delete ptr node\n");
delete(&ptr, NULL,ptr);
print_list(ptr);
return 0;
}
|