42-archive/ftp/libft/srcs/str/ft_strduptr.c
2017-10-08 12:28:04 +02:00

26 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strduptr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ariard <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/06 13:37:12 by ariard #+# #+# */
/* Updated: 2017/03/21 15:43:52 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strduptr(char *str, int (*is)(int c))
{
char *new;
char *tmp;
new = ft_memalloc(sizeof(char *) * ft_strlen(str) + 1);
tmp = new;
while (*str && (is)((int)*str))
*new++ = *str++;
*new = 0;
return (tmp);
}