summaryrefslogtreecommitdiffstats
path: root/example/stack.c
diff options
context:
space:
mode:
authorEthan Werner <mail@ethanwerner.com>2024-04-17 16:00:00 -0700
committerEthan Werner <mail@ethanwerner.com>2026-06-08 16:01:49 +0400
commitf6a144987cc403de8ad6bddd055f756120f8d405 (patch)
tree3b4cfc8c76db7adba8504dc0e079466e2a0d336c /example/stack.c
archival commit
Diffstat (limited to 'example/stack.c')
-rw-r--r--example/stack.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/example/stack.c b/example/stack.c
new file mode 100644
index 0000000..93128f4
--- /dev/null
+++ b/example/stack.c
@@ -0,0 +1,20 @@
+typedef double stack_value_t;
+
+#define STACK_IMPLEMENTATION
+#include "../include/stack.h"
+
+void main() {
+ stack_t stack = { .capacity = 10 };
+ stack_init(&stack);
+
+ for(int i = 0; i < 15; i++) {
+ stack_push(&stack, (stack_value_t) i);
+ }
+
+ printf("%lf\n", stack_peek(&stack));
+ printf("%lf\n", stack_pop(&stack));
+
+ for(int i = 0; i < 15; i++) {
+ printf("%lf\n", stack_pop(&stack));
+ }
+} \ No newline at end of file