/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_foreach.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: sgongas +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2026/02/22 23:44:08 by sgongas #+# #+# */ /* Updated: 2026/02/22 23:48:29 by sgongas ### ########.fr */ /* */ /* ************************************************************************** */ void ft_foreach(int *tab, int length, void (*f)(int)) { int i; i = 0; while (i < length) { f(tab[i]); i++; } } // #include // void ft_putchar(char c) // { // write(1, &c, 1); // } // void ft_putnbr(int nb) // { // if (nb == -2147483648) // { // write(1, "-2147483648", 11); // return ; // } // if (nb < 0) // { // ft_putchar('-'); // nb = -nb; // } // if (nb > 9) // ft_putnbr(nb / 10); // ft_putchar(nb % 10 + '0'); // } // int main(void) // { // int tab[] = {1,2,3,4}; // ft_foreach(tab, 4, &ft_putnbr); // return (0); // }