From 5ad31b7526e6fc91819a06857fb5db8e95988d66 Mon Sep 17 00:00:00 2001 From: Weber Date: Thu, 21 Mar 2024 21:18:54 +0000 Subject: [PATCH] skuska --- cv5/program.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index 417fc0e..de9de52 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -35,7 +35,7 @@ int main() { students_capacity = (students_capacity + 1) * 2; student_t *new_students = realloc(students, students_capacity * sizeof(student_t)); if (new_students == NULL) { - fprintf(stderr, "chyba"); + fprintf(stderr, "Error: Memory reallocation failed\n"); return 1; } students = new_students; @@ -54,9 +54,12 @@ int main() { if (strcmp(students[i].name, students[i - 1].name) != 0) { printf("%d %s\n", students[i].vote_count, students[i].name); } + } + + for (int i = 0; i < student_count; i++) { free(students[i].name); } free(students); return 0; -} \ No newline at end of file +}