From 0c730c6c4fcef5d10ba52fefba168228c5dbd087 Mon Sep 17 00:00:00 2001 From: Miloslav Macko Date: Mon, 15 Apr 2024 22:05:17 +0200 Subject: [PATCH] 111111 --- cv10/program.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index 4ea2bca..44359fd 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -11,8 +11,7 @@ int compare(const void* arg1, const void* arg2) { } int main() { - char* pole_smernikov[SIZE]; - memset(pole_smernikov, 0, SIZE * sizeof(char*)); + char* pole_smernikov[SIZE] = {NULL}; // Inicializujeme všetky smerníky na NULL int pocet_mien_v_poli = 0; char line[SIZE]; @@ -49,7 +48,10 @@ int main() { // Výpis prijatých a neprijatých študentov int max_students; - scanf("%d", &max_students); + if (scanf("%d", &max_students) != 1) { // Kontrola úspešnosti načítania + fprintf(stderr, "Chyba pri načítaní počtu študentov\n"); + exit(EXIT_FAILURE); + } printf("Prijati studenti:\n"); for (int i = 0; i < max_students && i < pocet_mien_v_poli; i++) {