29 lines
1.2 KiB
C
29 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strmap.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2016/11/03 14:58:24 by jhalford #+# #+# */
|
|
/* Updated: 2017/03/21 15:42:19 by jhalford ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strmap(char const *s, char (*f)(char))
|
|
{
|
|
size_t size;
|
|
size_t i;
|
|
char *out;
|
|
|
|
size = ft_strlen(s);
|
|
out = (char *)ft_malloc(sizeof(char) * (size + 1));
|
|
if (out == NULL)
|
|
return (NULL);
|
|
i = -1;
|
|
while (++i < size)
|
|
out[i] = (*f)(s[i]);
|
|
return (out);
|
|
}
|