aboutsummaryrefslogtreecommitdiff
path: root/test.c
diff options
context:
space:
mode:
authorCody <cody@codyq.dev>2023-06-26 07:20:34 -0500
committerCody <cody@codyq.dev>2023-06-26 07:20:34 -0500
commit849ba9ffa6ba9ac00bbc5fdb144a48cf7076a46f (patch)
tree071eaa4dbf30f590faecc4834f4d4a209413ddd2 /test.c
parent03021268fc319aa5e19e7bbcac226f3f626a6f84 (diff)
downloadsloth-849ba9ffa6ba9ac00bbc5fdb144a48cf7076a46f.tar.gz
Working dynamically sized arrays (syntax not right)
Diffstat (limited to 'test.c')
-rw-r--r--test.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/test.c b/test.c
index 26925e0..605ed13 100644
--- a/test.c
+++ b/test.c
@@ -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");
}