rt/libft/ft_strmap.c

31 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strmap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: scebula <scebula@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/26 10:43:35 by scebula #+# #+# */
/* Updated: 2015/11/26 10:51:04 by scebula ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strmap(char const *s, char (*f)(char))
{
char *str;
unsigned int i;
str = ft_strnew(ft_strlen(s));
if (str == NULL)
return (NULL);
i = 0;
while (s[i])
{
str[i] = f(s[i]);
i++;
}
return (str);
}