From caa09c8456af59b21b3dc1adffe10c430e287e0a Mon Sep 17 00:00:00 2001 From: Yevhen Kozirovskyi Date: Tue, 1 Oct 2024 21:57:29 +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 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index adc3dda..e627e03 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -26,11 +26,11 @@ int main() { int count = 0; - printf("Zadaj hladanu surovinu:"); + printf("Zadaj hladanu surovinu: "); fgets(ingredient, MAX_NAME_LEN, stdin); ingredient[strcspn(ingredient, "\n")] = '\0'; - printf("Zadaj jedalny listok:\n"); + printf("Zadaj jedalny listok: \n"); while (1) { char name[MAX_NAME_LEN], price[MAX_NAME_LEN]; @@ -52,7 +52,8 @@ int main() { int matches = 0; for (int i = 0; i < count; i++) { char decoded_name[MAX_NAME_LEN]; - strcpy(decoded_name, dishes[i][0]); + strncpy(decoded_name, dishes[i][0], MAX_NAME_LEN - 1); + decoded_name[MAX_NAME_LEN - 1] = '\0'; decodovane_slovo(decoded_name);