ft_strace/libft/ft_striteri.c

30 lines
1.2 KiB
C
Executable file

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_striteri.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/15 16:56:31 by thrieg #+# #+# */
/* Updated: 2025/02/16 19:04:45 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
//returns without doing anything if s or f are NULL, this is dumb because we
//can't report the error given the prototyping but I'm not taking any risk for
//my 3th retry...
void ft_striteri(char *s, void (*f)(unsigned int, char*))
{
unsigned int i;
if (!s || !f)
return ;
i = 0;
while (s[i])
{
f(i, &s[i]);
i++;
}
}