summaryrefslogtreecommitdiffhomepage
path: root/examples/stack.c
blob: de30c5b4fbd0a1336711acb9c76d74d144dc4fcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

#include <stdio.h>
#include <stc/cstr.h>
#include <stc/cstack.h>

declare_cvec(i, int);
declare_cstack(i, cvec_i);
declare_cstack(c, cstr);

int main() {
    cstack_i stack = cstack_i_init();
    cstack_c chars = cstack_c_init();

    for (int i=0; i<100; ++i)
        cstack_i_push(&stack, i*i);
    
    for (int i=0; i<90; ++i)
        cstack_i_pop(&stack);
    
    c_foreach (i, cstack_i, stack)
        printf("%d\n", *cstack_i_itval(i));
    printf("top: %d\n", *cstack_i_top(&stack));
}