diff options
| author | Cody <cody@codyq.dev> | 2023-06-26 07:20:34 -0500 |
|---|---|---|
| committer | Cody <cody@codyq.dev> | 2023-06-26 07:20:34 -0500 |
| commit | 849ba9ffa6ba9ac00bbc5fdb144a48cf7076a46f (patch) | |
| tree | 071eaa4dbf30f590faecc4834f4d4a209413ddd2 /test.c | |
| parent | 03021268fc319aa5e19e7bbcac226f3f626a6f84 (diff) | |
| download | sloth-849ba9ffa6ba9ac00bbc5fdb144a48cf7076a46f.tar.gz | |
Working dynamically sized arrays (syntax not right)
Diffstat (limited to 'test.c')
| -rw-r--r-- | test.c | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -1,13 +1,26 @@ #include <stdio.h> -long long hehehaha(); +typedef struct { + int size; + int cap; + long* inner; +} IntVec; -long long addz(long long lhs, long long rhs) { - return lhs + rhs + 1; -} +IntVec* test(); int main() { - long long res = hehehaha(); - printf("%d\n", res); - return 0; + IntVec* v = test(); + + int size = (*v).size; + int cap = (*v).cap; + long* inner = (*v).inner; + + printf("%d\n", size); + printf("%d\n", cap); + + for (int i = 0; i < size; ++i) { + long value = inner[i]; + printf("%d ", i); + } + puts("\n"); } |
