Initialization

This commit is contained in:
Kozar 2024-04-25 17:54:24 +02:00
parent 6527362089
commit 525ad77cc3

View File

@ -25,11 +25,10 @@ int main() {
memset(names, 0, sizeof(names));
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
int i, found = 0;
// Remove the newline character from the temp_name array
temp_name[strcspn(temp_name, "\n")] = '\0';
int i, found = 0;
for (i = 0; i < num_accepted; i++) {
if (strcmp(names[i], temp_name) == 0) {
found = 1;
@ -43,19 +42,20 @@ int main() {
}
num_students++;
// Check if we have reached the maximum number of accepted students
if (num_accepted == max_students) {
break;
break; // Exit the loop
}
}
qsort(names, num_accepted, sizeof(names[0]), compare_names);
if (num_accepted == 0) {
printf("Ziadne prihlasky");
printf("Ziadne prihlasky\n");
} else {
printf("Prijati studenti:\n");
for (int i = 0; i < num_accepted; i++) {
printf("%s", names[i]);
printf("%s\n", names[i]);
}
}