diff --git a/cv1/program.c b/cv1/program.c index 64ad8e6..43c71ab 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -33,16 +33,18 @@ int main() { decode(slovo); printf("Zadaj jedalny listok:\n"); while (1) { + if (fgets(dish_name, MAX_LENGTH, stdin) == NULL || strcmp(dish_name, "\n") == 0) { break; } dish_name[strcspn(dish_name, "\n")] = 0; - // Read the price as a float + if (scanf("%f", &price[count]) != 1) { break; } - // Clear the newline character left in the input buffer + while (getchar() != '\n'); + char normal_dish[MAX_LENGTH]; strcpy(normal_dish, dish_name); decode(normal_dish);