aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorkaiwu <kaiwu2004@gmail.com>2022-04-04 07:49:17 +0800
committerkaiwu <kaiwu2004@gmail.com>2022-04-04 07:49:17 +0800
commitecdce42a63557bcc653247ad77eaa30846a021f5 (patch)
tree593166fa54f5773fe4379d23704bc34152da3dd0 /src
parentad2f9dbe34ec79c0b9c23fea2ec5d963e9c05d5f (diff)
downloadadvent-of-code-ecdce42a63557bcc653247ad77eaa30846a021f5.tar.gz
advent-of-code-ecdce42a63557bcc653247ad77eaa30846a021f5.zip
fix gcc warnings
Diffstat (limited to 'src')
-rw-r--r--src/2016/day1/aoc.cpp4
-rw-r--r--src/2016/day1/aoc.h3
2 files changed, 3 insertions, 4 deletions
diff --git a/src/2016/day1/aoc.cpp b/src/2016/day1/aoc.cpp
index 8f79ece..114c290 100644
--- a/src/2016/day1/aoc.cpp
+++ b/src/2016/day1/aoc.cpp
@@ -6,8 +6,6 @@ instruction parse_day1(const char** pp) {
instruction i;
const char* p = *pp;
i.direction = (*p++) == 'R' ? instruction::right : instruction::left;
- i.distance = 0;
-
while (*p >= '0' && *p <= '9') {
i.distance = i.distance * 10 + *p - '0';
p++;
@@ -22,7 +20,7 @@ std::pair<int, int> day1(line_view file) {
std::vector<instruction> is;
bool found = false;
- position first;
+ position first{position::north, 0, 0};
const char* p1 = file.line;
const char* p2 = file.line + file.length;
diff --git a/src/2016/day1/aoc.h b/src/2016/day1/aoc.h
index b6e556e..b95813b 100644
--- a/src/2016/day1/aoc.h
+++ b/src/2016/day1/aoc.h
@@ -4,6 +4,7 @@
#include <math.h>
#include <set>
#include <vector>
+#include <functional>
namespace aoc2016 {
@@ -12,7 +13,7 @@ struct instruction {
left = 0,
right,
} direction;
- int distance;
+ int distance = 0;
};
struct position {