summaryrefslogtreecommitdiffstats
path: root/example/stack.c
diff options
context:
space:
mode:
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