piscine/c12/ex10/ft_list_foreach_if.c
Willem Haffmans 607ce08c18 all
2024-09-10 00:18:01 +02:00

29 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_list_foreach_if.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/03 18:11:50 by whaffman #+# #+# */
/* Updated: 2024/07/03 18:25:07 by whaffman ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_list.h"
void ft_list_foreach_if(
t_list *begin_list,
void (*f)(void *),
void *data_ref,
int (*cmp)()
)
{
while (begin_list)
{
if (!cmp(begin_list->data, data_ref))
f(begin_list->data);
begin_list = begin_list->next;
}
}