summaryrefslogtreecommitdiffhomepage
path: root/misc/examples/stack.c
diff options
context:
space:
mode:
authorTyge Løvset <[email protected]>2023-04-08 22:37:06 +0200
committerGitHub <[email protected]>2023-04-08 22:37:06 +0200
commit43120f2863a67db416ec3b379eb820e2704cafb7 (patch)
treef3b9917940f94c1582bc39ea6f56b735295ec861 /misc/examples/stack.c
parente8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff)
parent6426ac05eb8c4dc1ab22aae2eb4139f9671981b7 (diff)
downloadSTC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.tar.gz
STC-modified-43120f2863a67db416ec3b379eb820e2704cafb7.zip
Merge pull request #53 from tylov/dev42
Version 4.2 RC
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);
}