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]); }