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
| #include <stdlib.h>
typedef struct list_s list_t;
list_t *append(list_t **, int);
void clear(list_t **);
void remove_all(list_t **, int);
void dump(const list_t *);
int main(int argc, char *argv[]) {
(void)argc; (void)argv;
list_t *l = NULL;
dump(l);
append(&l, 42);
dump(l);
append(&l, -1);
append(&l, 10);
append(&l, -1);
append(&l, 2);
append(&l, 18);
append(&l, -1);
dump(l);
remove_all(&l, -1);
dump(l);
append(&l, 42);
append(&l, 123456789);
append(&l, 42);
dump(l);
remove_all(&l, 42);
dump(l);
clear(&l);
dump(l);
return 0;
} |
Partager