You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

35 lines
1.1 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/08/08 19:36:04 by emartine #+# #+# */
/* Updated: 2017/11/06 15:40:55 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *src)
{
size_t l;
size_t i;
char *r;
l = 0;
while (src[l])
l++;
r = (char *)malloc(l + 1);
if (r == NULL)
return (NULL);
i = 0;
while (src[i])
{
r[i] = src[i];
i++;
}
r[i] = '\0';
return (r);
}