From 3b299071d6be57be01ee1c7f89788e657ddf1f05 Mon Sep 17 00:00:00 2001 From: Yevhen Kozirovskyi Date: Thu, 3 Oct 2024 11:09:42 +0000 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=B1=D0=BD=D0=BE=D0=B2=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20cv1/program.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv1/program.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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);