From a56e7176ad621b6864124709bc4318ed2b5c5f56 Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 25 Apr 2024 20:05:11 +0200 Subject: [PATCH] Initialization --- cv10/program.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/cv10/program.c b/cv10/program.c index 520a872..de71e14 100644 --- a/cv10/program.c +++ b/cv10/program.c @@ -10,7 +10,7 @@ int main() { int count; char buffer[100]; char **applications; - int i; + int i, j; if (scanf("%d", &count) != 1 || count <= 0) { printf("Nespravny vstup\n"); @@ -30,7 +30,7 @@ int main() { buffer[len - 1] = '\0'; } int found = 0; - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { if (strcmp(applications[j], buffer) == 0) { found = 1; break; @@ -51,12 +51,19 @@ int main() { qsort(applications, i, sizeof(char *), compare_names); printf("Prijati studenti:"); - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { printf("%s\n", applications[j]); } + if (count < i) { + printf("Neprijati studenti:"); + for (; j < i; j++) { + printf("%s\n", applications[j]); + } + } + // Free allocated memory - for (int j = 0; j < i; j++) { + for (j = 0; j < i; j++) { free(applications[j]); } free(applications);