Initialization

This commit is contained in:
Kozar 2024-04-22 18:31:59 +02:00
parent 2484f0f10d
commit c430a567d7

View File

@ -15,9 +15,9 @@ int main() {
return 1; return 1;
} }
memset(names, 0, sizeof(names));
while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) { while (fgets(temp_name, sizeof(temp_name), stdin) != NULL && num_accepted < max_students) {
// Trim the newline character if present
temp_name[strcspn(temp_name, "\n")] = '\0';
int i, found = 0; int i, found = 0;
@ -38,17 +38,17 @@ int main() {
if (num_accepted == 0) { if (num_accepted == 0) {
printf("Ziadne prihlasky"); printf("Ziadne prihlasky");
} else { } else {
printf("Prijati studenti:\n"); printf("Prijati studenti:");
for (int i = 0; i < num_accepted; i++) { for (int i = 0; i < num_accepted; i++) {
printf("%s\n", names[i]); printf("%s", names[i]);
} }
} }
if (num_accepted < max_students && num_accepted < num_students) { if (num_accepted < num_students) {
printf("Neprijati studenti:\n"); printf("Neprijati studenti:");
for (int i = 0; i < max_students; i++) { for (int i = 0; i < max_students; i++) {
if (names[i][0] == '\0') { if (names[i][0] == '\0') {
printf("%s\n", names[i]); printf("%s", names[i]);
} }
} }
} }