summaryrefslogtreecommitdiff
path: root/2022/day08/main.c
diff options
context:
space:
mode:
Diffstat (limited to '2022/day08/main.c')
-rw-r--r--2022/day08/main.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/2022/day08/main.c b/2022/day08/main.c
new file mode 100644
index 0000000..f80b1d0
--- /dev/null
+++ b/2022/day08/main.c
@@ -0,0 +1,36 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc, char *argv[] )
+{
+ FILE *file = fopen(argv[1], "r");
+ size_t size;
+
+ fseek(file, 0, SEEK_END); // seek to end of file
+ size = ftell(file); // get current file pointer
+ fseek(file, 0, SEEK_SET); // seek back to beginning of file
+
+ char *line = NULL;
+ size_t len;
+ ssize_t nlen;
+ char *forrest, *pf;
+
+ while ((nlen = getline(&line, &len, file)) != -1)
+ {
+ if (forrest == 0)
+ {
+ forrest = pf = malloc( (size / nlen) * sizeof(char*) );
+ int i=0;
+ for (; *pf != 0; pf++)
+ {
+ i++;
+ }
+ printf("%d, %zu, %zd", i, size, nlen);
+ }
+
+ }
+
+
+}
+