-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstack_u32.c
39 lines (32 loc) · 846 Bytes
/
stack_u32.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
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <cdada/stack.h>
int main(int args, char** argv){
uint32_t item;
cdada_stack_t* s = cdada_stack_create(uint32_t);
//Push {1,3,5,4,6,5}
item = 1;
cdada_stack_push(s, &item);
item = 3;
cdada_stack_push(s, &item);
item = 5;
cdada_stack_push(s, &item);
item = 4;
cdada_stack_push(s, &item);
item = 6;
cdada_stack_push(s, &item);
item = 5;
cdada_stack_push(s, &item);
fprintf(stdout, "The stack has a size of %u:\n", cdada_stack_size(s));
uint32_t val;
cdada_stack_top(s, &val);
fprintf(stdout, "Popping %u off the stack:\n", val);
cdada_stack_pop(s);
fprintf(stdout, "After removal of top, the stack has a size of %u, contents:\n",
cdada_stack_size(s));
cdada_stack_print(s, stdout);
//Don't leak
cdada_stack_destroy(s);
return EXIT_SUCCESS;
}