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