]>
Commit | Line | Data |
---|---|---|
d104c687 MR |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include "queue.h" | |
4 | #include "stack.h" | |
5 | ||
6 | int main() { | |
7 | Stack* stack = stack_init(); | |
8 | if (stack_empty(stack)) | |
9 | printf("Stack is empty\n"); | |
10 | ||
11 | int* i = malloc(sizeof(int*)); | |
12 | *i = 10; | |
13 | stack_push(stack, i); | |
14 | int* j = malloc(sizeof(int*)); | |
15 | *j = 5; | |
16 | stack_push(stack, j); | |
17 | int* val = stack_pop(stack); | |
18 | printf("Stack back: %i\n", *val); | |
19 | free(val); | |
20 | void** elems = stack_clear(&stack); | |
21 | for (int i = 0; elems[i]; i++) | |
22 | free(elems[i]); | |
23 | free(elems); | |
24 | ||
25 | return 0; | |
26 | } | |
27 |