Initialization

This commit is contained in:
Kozar 2024-03-21 14:09:15 +01:00
parent 11340969ad
commit 2c59b0295e
2 changed files with 7 additions and 2 deletions

View File

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

View File

@ -3,3 +3,9 @@ int main() {
return 0;
}
#define SIZE 100
struct student {
char name[SIZE];
int votes;
};