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 +}