diff options
| author | Tyge Løvset <[email protected]> | 2020-09-02 19:49:51 +0200 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2020-09-02 19:49:51 +0200 |
| commit | af12926547b1a09b4513ba149d13ea9f84d4c528 (patch) | |
| tree | 954ab763d10a2c5558163645004b9c11ed63b5d1 /examples/stack.c | |
| parent | 1b46028f4636c78af40c37dbc55d76598996a5b7 (diff) | |
| download | STC-modified-af12926547b1a09b4513ba149d13ea9f84d4c528.tar.gz STC-modified-af12926547b1a09b4513ba149d13ea9f84d4c528.zip | |
Added cqueue.h and cstack.h adapters. Updated cpqueue.h API to be more consistent.
Diffstat (limited to 'examples/stack.c')
| -rw-r--r-- | examples/stack.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/examples/stack.c b/examples/stack.c new file mode 100644 index 00000000..2aa8364b --- /dev/null +++ b/examples/stack.c @@ -0,0 +1,18 @@ +
+#include <stc/cstack.h>
+#include <stdio.h>
+
+declare_cvec(i, int);
+declare_cstack(i, cvec_i);
+
+int main() {
+ cstack_i stack = cstack_i_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);
+
+ printf("top: %d\n", *cstack_i_top(&stack));
+}
\ No newline at end of file |
