summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/stack.c
diff options
context:
space:
mode:
Diffstat (limited to 'misc/examples/stack.c')
-rw-r--r--misc/examples/stack.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/misc/examples/stack.c b/misc/examples/stack.c
index 50dc8eb7..c817e1ae 100644
--- a/misc/examples/stack.c
+++ b/misc/examples/stack.c
@@ -11,20 +11,22 @@
#include <stc/cstack.h>
int main() {
- c_auto (cstack_i, stack)
- c_auto (cstack_c, chars)
- {
- c_forrange (i, 101)
- cstack_i_push(&stack, (int)(i*i));
-
- printf("%d\n", *cstack_i_top(&stack));
-
- c_forrange (i, 90)
- cstack_i_pop(&stack);
-
- c_foreach (i, cstack_i, stack)
- printf(" %d", *i.ref);
- puts("");
- printf("top: %d\n", *cstack_i_top(&stack));
- }
+ cstack_i stack = {0};
+ cstack_c chars = {0};
+
+ c_forrange (i, 101)
+ cstack_i_push(&stack, (int)(i*i));
+
+ printf("%d\n", *cstack_i_top(&stack));
+
+ c_forrange (i, 90)
+ cstack_i_pop(&stack);
+
+ c_foreach (i, cstack_i, stack)
+ printf(" %d", *i.ref);
+ puts("");
+ printf("top: %d\n", *cstack_i_top(&stack));
+
+ cstack_i_drop(&stack);
+ cstack_c_drop(&chars);
}