From df9ffd14382b139ff6dd1032fc28d31e4b8105c8 Mon Sep 17 00:00:00 2001 From: an760cw Date: Sat, 30 Sep 2023 16:07:46 +0200 Subject: [PATCH] program.c --- cv1/program.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/cv1/program.c b/cv1/program.c index d38d21e..a00a77d 100644 --- a/cv1/program.c +++ b/cv1/program.c @@ -16,7 +16,7 @@ int read_pizza(struct pizza* element); void transform(char* str); int main() { - struct pizza jedalny_listok[5]; // Použité priamo číslo 5 namiesto POCET_JEDAL + struct pizza jedalny_listok[5]; memset(jedalny_listok, 0, sizeof(struct pizza) * 5); int counter = 0; @@ -26,7 +26,10 @@ int main() { printf("Zadaj hladanu surovinu:\n"); fgets(line, LINESIZE, stdin); - //trim(line); + int len = strlen(line); + if (len > 0 && line[len - 1] == '\n') { + line[len - 1] = '\0'; // Odstráňye znak nového riadku + } if (strlen(line) > 1) { printf("Zadaj jedalny listok:\n"); @@ -37,7 +40,7 @@ int main() { jedalny_listok[counter].price = element.price; counter++; - if (counter >= 5) { // Použité priamo číslo 5 namiesto POCET_JEDAL + if (counter >= 5) { break; } } @@ -59,13 +62,6 @@ int main() { return 0; } -//void trim(char* str) { - //int i = 0; - //while (str[i] != '\n' && str[i] != 0) { - //i++; - //} - //str[i] = 0; -//} int search_string(const char* a, const char* b) { int c = strlen(b);