Initialization

This commit is contained in:
Kozar 2024-04-25 19:41:36 +02:00
parent bb61811d78
commit 107d2b702a

View File

@ -24,7 +24,10 @@ int main() {
}
i = 0;
while (i < count && fgets(buffer, sizeof(buffer), stdin)) {
while (fgets(buffer, sizeof(buffer), stdin)) {
if (buffer[0] == '\n' || i >= count) { // End of input or reached maximum count
break;
}
int len = strlen(buffer);
if (len > 0 && buffer[len - 1] == '\n') { // Remove newline character if present
buffer[len - 1] = '\0';
@ -50,13 +53,13 @@ int main() {
// Sort the applications alphabetically
qsort(applications, i, sizeof(char *), compare_names);
printf("Prijati studenti:");
printf("Prijati studenti:\n");
for (j = 0; j < i; j++) {
printf("%s\n", applications[j]);
}
if (count < i) {
printf("Neprijati studenti:");
printf("Neprijati studenti:\n");
for (; j < i; j++) {
printf("%s\n", applications[j]);
}