diff options
| author | Tyge Løvset <[email protected]> | 2023-03-26 00:27:45 +0100 |
|---|---|---|
| committer | Tyge Løvset <[email protected]> | 2023-03-26 00:27:45 +0100 |
| commit | eb85069b669e754836b9d4587ba03d3af1a5e975 (patch) | |
| tree | 45c9a0d3fe40c59a8b33ae8ecd2e7aa78bef6240 /misc/examples/stack.c | |
| parent | e8be14dfc894eeac859f0287d4d5b4f4745c0585 (diff) | |
| download | STC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.tar.gz STC-modified-eb85069b669e754836b9d4587ba03d3af1a5e975.zip | |
development branch for 4.2
Removed uses of c_auto and c_with in documentation examples and code examples. Still using c_defer a few places.
Renamed c11/fmt.h to c11/print.h.
Some additions in ccommon.h, e.g. c_const_cast(T, x).
Improved docs.
Diffstat (limited to 'misc/examples/stack.c')
| -rw-r--r-- | misc/examples/stack.c | 34 |
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); } |
