From b3e37838ffc01e0aefb48943c26f97cb7398fb05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Gejdo=C5=A1?= Date: Wed, 11 Mar 2026 13:00:21 +0000 Subject: [PATCH] skusim osetrit fakt zly vstup --- du2/program.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/du2/program.c b/du2/program.c index 2067ee2..c4d5e4a 100644 --- a/du2/program.c +++ b/du2/program.c @@ -34,10 +34,13 @@ int main() { char name[SIZE]; int velkost_zoznamu = 0; //pocet studentov + if ((fgets (vstup, SIZE, stdin) != NULL) && (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2)) { + printf("Nepodarilo sa nacitat nic\n"); + return 0; + } while (fgets (vstup, SIZE, stdin) != NULL) { //citat input, kontrola ci existuje, pridat hlasy existujucemu zaznamu if (sscanf(vstup, "%d %[^\n]", &hlasy, name) != 2) { - printf("Nepodarilo sa nacitat nic\n"); break; } existuje = 0;