Fixed zero initializers

This commit is contained in:
Hugo Mårdbrink 2021-12-09 01:18:52 +01:00
parent ab21e8ad7d
commit df8bddb55a
4 changed files with 14 additions and 10 deletions

View file

@ -8,9 +8,9 @@ const std::vector<std::string>& readToString(const std::string& path);
int main()
{
std::vector<std::string> commands = readToString("../input/02.txt");
long h,d = 0;
long h{},d{};
for(auto& command : commands)
for(std::string command : commands)
{
command.pop_back();
int val = command.back() - 48;
@ -23,7 +23,7 @@ int main()
}
}
std::cout << d*h << std::endl;
std::cout << h*d << std::endl;
return 0;
}
@ -33,9 +33,11 @@ const std::vector<std::string>& readToString(const std::string& path)
std::ifstream inputFile(path);
std::string input;
static std::vector<std::string> inputs;
while(std::getline(inputFile, input))
inputs.push_back(input);
inputFile.close();
return inputs;
}