summaryrefslogtreecommitdiffhomepage
path: root/examples/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stack.c')
-rw-r--r--examples/stack.c18
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