From c2e16f54da6b1d0f8a6b352881b08143c9f41f15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ka=C4=8Dm=C3=A1r?= Date: Wed, 19 Mar 2025 18:38:09 +0000 Subject: [PATCH] Update du4/program.c --- du4/program.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/du4/program.c b/du4/program.c index 17e8fc8..757e820 100644 --- a/du4/program.c +++ b/du4/program.c @@ -1,6 +1,7 @@ #include #include #include +#include #define MAX_NAME 100 #define MAX_ENTRIES 100 @@ -49,16 +50,20 @@ int main() { int has_data = 0; while (fgets(line, sizeof(line), stdin)) { + // Preskočí prázdne riadky + if (strlen(line) <= 1) continue; + if (sscanf(line, "%d %[^\n]", &votes, name) != 2 || votes < 0) { - break; + continue; // Namiesto prerušenia len ignoruje neplatné riadky } + Student *student = find_or_add(name); if (student) student->votes += votes; has_data = 1; } if (!has_data) { - printf("Chyba: Nebol zadany platny vstup.\n"); + printf("Nepodarilo nacitat nic\n"); return 1; }