diff --git a/ex1/main.c b/ex1/main.c index ec29406e3eb904fa3ebac654660801d30b5ccedf..ef3b5de00c2feb1d47b853628324a9e2d44e3e51 100644 --- a/ex1/main.c +++ b/ex1/main.c @@ -1,6 +1,6 @@ /** * @file main.c - * @author Prénom Nom + * @author Florian Burgener * @brief Exercice 1 * @version 1.0 * @date 2021-12-07 @@ -9,31 +9,32 @@ * */ -#include <math.h> -#include <stdbool.h> +#include <ctype.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <ctype.h> int main() { - char str1[100]; - char str2[100]; + // 80 characters + 1 (null character). + char str1[81]; + char str2[81]; scanf("%s", str1); scanf("%s", str2); + printf("%s\n", str1); if (strlen(str1) != strlen(str2)) { + // Strings do not have the same length. printf("\ndistance: -1\n"); return EXIT_FAILURE; } int32_t distance = 0; - + + // Calculation of the distance. for (int32_t i = 0; i < (int32_t)strlen(str1); i += 1) { distance += abs(toupper(str1[i]) - toupper(str2[i])); - } printf("\ndistance: %d\n", distance);