piscine-c11/ex02/ft_any.c

29 lines
406 B
C

#include <stdlib.h>
int ft_any(char **tab, int(*f)(char*))
{
while (*tab)
if (f(*tab++))
return (1);
return (0);
}
#include <stdio.h>
int ft_is_empty(char *str)
{
return (*str == 0);
}
int main(void)
{
char **strs;
strs = malloc(sizeof(char *) * 4);
strs[0] = "Hey";
strs[1] = "s";
strs[2] = "Ho";
strs[3] = "";
printf("%d\n", ft_any(strs, &ft_is_empty));
free(strs);
}