From 2c59b0295ecb0b67a3577d7540c50248fd37fe97 Mon Sep 17 00:00:00 2001 From: ak643du Date: Thu, 21 Mar 2024 14:09:15 +0100 Subject: [PATCH] Initialization --- cv4/list_ops.c | 3 +-- cv5/program.c | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) 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; +};