From 2a868dd92be5e31e2f9c5d565840d782d9d4f7bd Mon Sep 17 00:00:00 2001 From: Yevhen Kozirovskyi Date: Wed, 2 Oct 2024 17:05:35 +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, 5 insertions(+), 1 deletion(-) diff --git a/cv1/program.c b/cv1/program.c index 808b531..86ed403 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -38,6 +38,7 @@ int main() { if (fgets(name, MAX_NAME_LEN, stdin) == NULL) { return 0; } + name[strcspn(name, "\n")] = '\0'; if (strlen(name) == 0) { break; @@ -45,6 +46,7 @@ int main() { if (fgets(price, MAX_NAME_LEN, stdin) == NULL) { return 0; } + price[strcspn(price, "\n")] = '\0'; strncpy(dishes[count][0], name, MAX_NAME_LEN - 1); dishes[count][0][MAX_NAME_LEN - 1] = '\0'; @@ -65,7 +67,9 @@ int main() { if (strstr(decoded_name, ingredient) != NULL) { printf("%s%s", dishes[i][0], dishes[i][1]); - + if (i < count - 1) { + printf("\n"); + } } } printf("Nacitanych %d poloziek.", count);