From bb61811d78af371b30e88f12633367c8606bbdde Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 25 Apr 2024 19:34:23 +0200 Subject: [PATCH] Initialization --- cv10/program.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index 6e7c5a1..de71e14 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -24,10 +24,7 @@ int main() { } i = 0; - while (fgets(buffer, sizeof(buffer), stdin)) { - if (buffer[0] == '\n' || i >= count) { // End of input or reached maximum count - break; - } + while (i < count && fgets(buffer, sizeof(buffer), stdin)) { int len = strlen(buffer); if (len > 0 && buffer[len - 1] == '\n') { // Remove newline character if present buffer[len - 1] = '\0'; @@ -53,13 +50,13 @@ int main() { // Sort the applications alphabetically qsort(applications, i, sizeof(char *), compare_names); - printf("Prijati studenti:\n"); + printf("Prijati studenti:"); for (j = 0; j < i; j++) { printf("%s\n", applications[j]); } if (count < i) { - printf("Neprijati studenti:\n"); + printf("Neprijati studenti:"); for (; j < i; j++) { printf("%s\n", applications[j]); }