diff --git a/du1/output/program.exe b/du1/output/program.exe index 7122c2a..e160287 100644 Binary files a/du1/output/program.exe and b/du1/output/program.exe differ diff --git a/du1/program.c b/du1/program.c index 37d3a16..8a00232 100644 --- a/du1/program.c +++ b/du1/program.c @@ -84,7 +84,7 @@ int read_pizza (struct pizza* item) { } Line_druha [strcspn(Line_druha, "\n")] = '\0'; float value; - if (sscanf(Line_jeden, "%f", &value ) !=1) { + if (sscanf(Line_druha, "%f", &value ) !=1) { return 0; } item->prize = value; @@ -95,28 +95,29 @@ int read_pizza (struct pizza* item) { int main() { - char poisk[LINESIZE]; + char s_item[LINESIZE]; + struct pizza menu[MAX_PIZZAS]; + int pocet = 0; + printf("Zadaj hladanu surovinu:\n"); - fgets(poisk, sizeof(poisk), stdin); + fgets(s_item, sizeof(s_item), stdin); + s_item[strcspn(s_item, "\n")] = '\0'; - poisk[strcspn(poisk, "\n")] = '\0'; - struct pizza jedalny_listok [MAX_PIZZAS]; + printf("Zadaj hlavny listok:\n"); + + while (pocet < MAX_PIZZAS && read_pizza(&menu[pocet])) { + pocet++; + } + + for (int i = 0; i < pocet; i++) { + if (search_string(menu[i].name, s_item) !=-1) { + printf("%s\n", menu[i].name); + printf("%.2f\n", menu[i].prize); + } + } + + printf("Nacitannych %s poloziek.\n", pocet); - int vsetky = 0; - while (vsetky