-
Notifications
You must be signed in to change notification settings - Fork 0
/
LIST.C
64 lines (47 loc) · 1.03 KB
/
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
64
/*
The^day^of^DooM
Borland C++ 3.1
Create Date: 26.12.2007
Last Update: 28.12.2007
Last Update: 12.07.2008
Full Channge: 30.04.2010
Last Update: 30.04.2010
*/
#include <stdio.h>
#include <conio.h>
#include "src/list.h"
typedef struct node {
unsigned int id;
} DATA, *LPDATA;
void freeData(void *node)
{
printf("free id: %d\n", ((LPDATA)node)->id);
}
void main(void)
{
LPDATA newNode, temp;
LPLIST root = NULL, current;
clrscr();
newNode = (LPDATA)malloc(sizeof(DATA));
newNode->id = 0;
addToList(&root, (void*)newNode, freeData);
newNode = (LPDATA)malloc(sizeof(DATA));
newNode->id = 1;
addToList(&root, (void*)newNode, NULL);
newNode = (LPDATA)malloc(sizeof(DATA));
newNode->id = 2;
addToList(&root, (void*)newNode, freeData);
removeFromList(&root, 1);
current = root;
while(current) {
temp = (LPDATA)current->lpData;
printf("ID: %d\n", temp->id);
current = current->next;
}
while(root) {
current = root;
printf("Remove ID: %d\n", current->id);
removeFromList(&root, current->id);
}
getch();
}