fix dalsi asi

This commit is contained in:
Michal Utľák 2024-04-22 17:34:55 +02:00
parent fc66796acc
commit f43431e8fc

View File

@ -7,8 +7,8 @@ int main() {
int pocet_studentov = 0; int pocet_studentov = 0;
int ziadne_mena = 1; int ziadne_mena = 1;
char first_input[100]; char prvy_input[100];
if (fgets(first_input, sizeof(first_input), stdin) == NULL) { if (fgets(prvy_input, sizeof(prvy_input), stdin) == NULL || atoi(prvy_input) <= 0) {
printf("Nespravny vstup\n"); printf("Nespravny vstup\n");
return 1; return 1;
} }
@ -50,7 +50,7 @@ int main() {
} }
printf("Prijati studenti:\n"); printf("Prijati studenti:\n");
int pocet = atoi(first_input); int pocet = atoi(prvy_input);
for (int i = 0; i < pocet && i < pocet_studentov; i++) { for (int i = 0; i < pocet && i < pocet_studentov; i++) {
printf("%s\n", pole[i]); printf("%s\n", pole[i]);
} }