calibration : ajout de newlines pour la lisibilité
This commit is contained in:
parent
eb0b69bef4
commit
31dcab5853
1 changed files with 4 additions and 0 deletions
|
@ -47,16 +47,20 @@ unsigned int get_calibration_sum(FILE *input_file) {
|
||||||
unsigned int sum = 0;
|
unsigned int sum = 0;
|
||||||
char *current_line, *reversed_line;
|
char *current_line, *reversed_line;
|
||||||
char intermediate_buffer[3];
|
char intermediate_buffer[3];
|
||||||
|
|
||||||
intermediate_buffer[2] = '\0';
|
intermediate_buffer[2] = '\0';
|
||||||
|
|
||||||
while (!feof(input_file)) {
|
while (!feof(input_file)) {
|
||||||
current_line = read_line(input_file);
|
current_line = read_line(input_file);
|
||||||
reversed_line = strrev(current_line);
|
reversed_line = strrev(current_line);
|
||||||
|
|
||||||
if (*current_line != '\0') {
|
if (*current_line != '\0') {
|
||||||
intermediate_buffer[0] = first_digit(current_line);
|
intermediate_buffer[0] = first_digit(current_line);
|
||||||
intermediate_buffer[1] = first_digit(reversed_line);
|
intermediate_buffer[1] = first_digit(reversed_line);
|
||||||
|
|
||||||
sum += atoi(intermediate_buffer);
|
sum += atoi(intermediate_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
free(reversed_line);
|
free(reversed_line);
|
||||||
free(current_line);
|
free(current_line);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue