From b84610cbbc60b3bdd400e5c2c0176de39f0c162e Mon Sep 17 00:00:00 2001 From: Bohdana Marchenko Date: Thu, 20 Mar 2025 22:18:20 +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=20du4/program.c?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- du4/program.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/du4/program.c b/du4/program.c index a669d39..2d7b0be 100644 --- a/du4/program.c +++ b/du4/program.c @@ -38,8 +38,8 @@ int main() { while (fgets(line, SIZE, stdin) != NULL) { char *end = NULL; int votes = strtol(line, &end, 10); - if (votes == 0) { - continue; // Neplatný vstup, preskočiť + if (end == line || *end == '\0' || votes <= 0) { + break; // Neplatný vstup, ukončiť načítanie } // Preskočiť medzeru po čísle hlasov