Initialization
This commit is contained in:
parent
25fd4de705
commit
67dad58059
@ -15,10 +15,13 @@ int main() {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initialize the names array to all-zero strings
|
||||||
|
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) {
|
||||||
size_t len = strlen(temp_name);
|
size_t len = strlen(temp_name);
|
||||||
if (len > 0 && temp_name[len-1] == '\n') {
|
if (len > 0 && temp_name[len-1] == '\n') {
|
||||||
temp_name[len-1] = '\0';
|
temp_name[len-1] = '\0'; // remove newline character
|
||||||
}
|
}
|
||||||
|
|
||||||
int i, found = 0;
|
int i, found = 0;
|
||||||
@ -41,16 +44,14 @@ int main() {
|
|||||||
} else {
|
} else {
|
||||||
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\n", names[i]);
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (num_accepted < max_students) {
|
if (num_accepted < max_students) {
|
||||||
printf("Neprijati studenti:\n");
|
printf("Neprijati studenti:\n");
|
||||||
for (int i = num_accepted; i < max_students; i++) {
|
for (int i = num_accepted; i < max_students; i++) {
|
||||||
printf("%s", names[i]);
|
printf("%s\n", names[i]);
|
||||||
printf("\n");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user