summaryrefslogtreecommitdiffstats
path: root/2021/day2/pilot.c
diff options
context:
space:
mode:
authorYigit Sever2021-12-06 20:36:43 +0300
committerYigit Sever2021-12-06 20:36:43 +0300
commitce9b9c411bd6c36d80fe6dd8112c8188661e2844 (patch)
tree07b3b56fb538246c411803adb5f922e91bbecaf0 /2021/day2/pilot.c
parent9324fbc1cfd397d803a255c958d51d258bd4aa7c (diff)
downloadaoc-ce9b9c411bd6c36d80fe6dd8112c8188661e2844.tar.gz
aoc-ce9b9c411bd6c36d80fe6dd8112c8188661e2844.tar.bz2
aoc-ce9b9c411bd6c36d80fe6dd8112c8188661e2844.zip
2021, day2: start
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}