diff --git a/cv4/list_ops.c b/cv4/list_ops.c index 4bf4a64..5bf3323 100644 --- a/cv4/list_ops.c +++ b/cv4/list_ops.c @@ -52,10 +52,9 @@ list_t *filter_list(list_t *list, bool (*filter)(list_element_t)) { list_t *filtered = malloc(sizeof(list_t) + filteredLength * sizeof(list_element_t)); if (filtered != NULL) { filtered->length = filteredLength; - size_t j = 0; for (size_t i = 0; i < list->length; ++i) { if (filter(list->elements[i])) { - filtered->elements[j++] = list->elements[i]; + filtered->elements[i] = list->elements[i]; } } } diff --git a/cv5/program.c b/cv5/program.c index 4f791d9..80f59b7 100644 --- a/cv5/program.c +++ b/cv5/program.c @@ -3,3 +3,9 @@ int main() { return 0; } +#define SIZE 100 + +struct student { + char name[SIZE]; + int votes; +};