diff --git a/cv1/program.c b/cv1/program.c index 59381f4..ce7f787 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -28,12 +28,7 @@ char hacker_script(char l) { void transform_to_hacker_script(const char *src, char *dest) { while (*src) { - if (isupper(*src)) { - *dest++ = tolower(*src); - } else { - *dest++ = hacker_script(*src); - } - src++; + *dest++ = hacker_script(*src++); } *dest = '\0'; } @@ -44,7 +39,7 @@ int contains_normalized(const char *name, const char *search) { transform_to_hacker_script(name, transformed_name); transform_to_hacker_script(search, transformed_search); - return strcasestr(transformed_name, transformed_search) != NULL; + return strstr(transformed_name, transformed_search) != NULL; } int read_pizza(struct pizza *item) { @@ -59,12 +54,7 @@ int read_pizza(struct pizza *item) { return 0; } - char *endptr; - item->price = strtof(line, &endptr); - if (endptr == line || *endptr != '\n') { - return 0; - } - + item->price = strtof(line, NULL); return 1; } @@ -77,10 +67,6 @@ int main() { fgets(search, LINESIZE, stdin); search[strcspn(search, "\n")] = '\0'; - for (int i = 0; search[i]; i++) { - search[i] = tolower(search[i]); - } - printf("Zadaj jedalny listok:\n"); while (read_pizza(&menu[count])) { count++; @@ -89,9 +75,6 @@ int main() { int found_count = 0; for (int i = 0; i < count; i++) { if (contains_normalized(menu[i].name, search)) { - if (found_count == 0) { - printf("\nVysledky vyhladavania:\n"); - } printf("%s\n%.2f\n", menu[i].name, menu[i].price); found_count++; }