From 9850cd54637044dbe63b9f6f70fd657ae26f973d Mon Sep 17 00:00:00 2001 From: Weber Date: Thu, 21 Mar 2024 21:09:05 +0000 Subject: [PATCH] skuska --- cv5/program.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/cv5/program.c b/cv5/program.c index 00a967e..3adad93 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -8,8 +8,8 @@ typedef struct student { } student_t; int compare_students(const void *a, const void *b) { - const student_t *student_a = a; - const student_t *student_b = b; + const student_t *student_a = (const student_t *)a; + const student_t *student_b = (const student_t *)b; if (student_a->vote_count > student_b->vote_count) { return -1; @@ -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, "Error"); + fprintf(stderr, "Chyba"); return 1; } students = new_students; @@ -51,12 +51,9 @@ int main() { printf("Results:\n"); for (int i = 0; i < student_count; i++) { 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 +}