From 849ba9ffa6ba9ac00bbc5fdb144a48cf7076a46f Mon Sep 17 00:00:00 2001 From: Cody Date: Mon, 26 Jun 2023 07:20:34 -0500 Subject: Working dynamically sized arrays (syntax not right) --- test.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'test.c') diff --git a/test.c b/test.c index 26925e0..605ed13 100644 --- a/test.c +++ b/test.c @@ -1,13 +1,26 @@ #include -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"); } -- cgit v1.2.3