This commit is contained in:
root
2026-02-23 00:04:03 +00:00
commit fadb328b05
17 changed files with 573 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_foreach.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgongas <sgongas@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* 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 <unistd.h>
// 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);
// }