From f43431e8fcfc4d1c0a4198efeb5485f1926149e5 Mon Sep 17 00:00:00 2001 From: Michal Utlak Date: Mon, 22 Apr 2024 17:34:55 +0200 Subject: [PATCH] fix dalsi asi --- cv10/program.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index 646e6ef..1ccc395 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -7,10 +7,10 @@ int main() { int pocet_studentov = 0; int ziadne_mena = 1; - char first_input[100]; - if (fgets(first_input, sizeof(first_input), stdin) == NULL) { + char prvy_input[100]; + if (fgets(prvy_input, sizeof(prvy_input), stdin) == NULL || atoi(prvy_input) <= 0) { printf("Nespravny vstup\n"); - return 1; + return 1; } while (fgets(pole[pocet_studentov], sizeof(pole[pocet_studentov]), stdin) != NULL) { @@ -50,7 +50,7 @@ int main() { } printf("Prijati studenti:\n"); - int pocet = atoi(first_input); + int pocet = atoi(prvy_input); for (int i = 0; i < pocet && i < pocet_studentov; i++) { printf("%s\n", pole[i]); }