From 2d6971997a440e785c98840f4f5bd4f9cd536585 Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 25 Apr 2024 18:05:26 +0200 Subject: [PATCH] Initialization --- cv10/program.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index 01c0cf5..3dfb878 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -18,6 +18,7 @@ int main() { memset(names, 0, sizeof(names)); while (fgets(temp_name, sizeof(temp_name), stdin)!= NULL && num_accepted < max_students) { + temp_name[strcspn(temp_name, "\n")] = '\0'; int i, found = 0; @@ -40,12 +41,13 @@ int main() { } else { printf("Prijati studenti:"); for (int i = 0; i < num_accepted; i++) { - printf("%s", names[i]); + printf("%s\n", names[i]); } if (num_students > num_accepted) { printf("Neprijati studenti:"); for (int i = 0; i < num_students; i++) { + strcpy(temp_name, names[i]); int found = 0; for (int j = 0; j < num_accepted; j++) { if (strcmp(names[j], temp_name) == 0) { @@ -54,11 +56,11 @@ int main() { } } if (!found) { - printf("%s", temp_name); + printf("%s\n", temp_name); } } } } return 0; -} \ No newline at end of file +}