summaryrefslogtreecommitdiffstats
path: root/2021/day2/pilot.c
diff options
context:
space:
mode:
Diffstat (limited to '2021/day2/pilot.c')
-rw-r--r--2021/day2/pilot.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/2021/day2/pilot.c b/2021/day2/pilot.c
new file mode 100644
index 0000000..4268cc7
--- /dev/null
+++ b/2021/day2/pilot.c
@@ -0,0 +1,34 @@
1#include <stdio.h>
2#include <stdlib.h>
3#include <string.h>
4
5int main(int argc, char *argv[])
6{
7 if (argc != 2) {
8 printf("Usage: ./depth <input-file>\n");
9 exit(EXIT_FAILURE);
10 }
11
12 FILE *fp;
13 char *buffer;
14 ssize_t read;
15 size_t len = 0;
16
17 fp = fopen(argv[1], "r");
18 if (fp == NULL) {
19 perror("fopen");
20 exit(EXIT_FAILURE);
21 }
22
23 int scalar;
24 char *way;
25 while ((read = getline(&buffer, &len, fp)) != -1) {
26 sscanf(buffer, "%s %d", way, &scalar);
27 // printf("READ: <%s>, <%d>\n", way, scalar);
28
29 if (strncmp(buffer, "forward", strlen(buffer))) {
30 }
31 }
32
33 return 0;
34}