This commit is contained in:
Weber 2024-03-21 21:18:54 +00:00
parent 9b16a7ae19
commit 5ad31b7526

View File

@ -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;
}
}