Initialization
This commit is contained in:
parent
11340969ad
commit
2c59b0295e
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,3 +3,9 @@ int main() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define SIZE 100
|
||||
|
||||
struct student {
|
||||
char name[SIZE];
|
||||
int votes;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user