Initialization

This commit is contained in:
Kozar 2024-04-22 17:43:31 +02:00
parent 134344fe10
commit 70ce17da57

View File

@ -15,11 +15,9 @@ int main() {
return 1; return 1;
} }
// Initialize the names array to all-zero strings
memset(names, 0, sizeof(names)); 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) {
// Remove newline character from temp_name
int i, found = 0; int i, found = 0;
@ -42,9 +40,6 @@ int main() {
printf("Prijati studenti:\n"); printf("Prijati studenti:\n");
for (int i = 0; i < num_accepted; i++) { for (int i = 0; i < num_accepted; i++) {
printf("%s", names[i]); printf("%s", names[i]);
if (i < num_accepted - 1) {
printf("\n");
}
} }
} }