From d97efb1f8e2860a72b3e66805e6c9646572700a9 Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 25 Apr 2024 20:34:12 +0200 Subject: [PATCH] Initialization --- cv10/program.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index e875594..de71e14 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -29,8 +29,17 @@ int main() { if (len > 0 && buffer[len - 1] == '\n') { // Remove newline character if present buffer[len - 1] = '\0'; } - applications[i] = strdup(buffer); - i++; + int found = 0; + for (j = 0; j < i; j++) { + if (strcmp(applications[j], buffer) == 0) { + found = 1; + break; + } + } + if (!found) { + applications[i] = strdup(buffer); + i++; + } } if (i == 0) { @@ -43,7 +52,7 @@ int main() { printf("Prijati studenti:"); for (j = 0; j < i; j++) { - printf("%s", applications[j]); + printf("%s\n", applications[j]); } if (count < i) {