31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: tchivert <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/04/04 17:30:33 by tchivert #+# #+# */
|
|
/* Updated: 2019/09/04 05:13:32 by tchivert ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *str)
|
|
{
|
|
int i;
|
|
char *dest;
|
|
|
|
i = 0;
|
|
if (!(dest = (char *)malloc(sizeof(char) * (ft_strlen((char *)str) + 1))))
|
|
return (NULL);
|
|
while (str[i])
|
|
{
|
|
dest[i] = str[i];
|
|
i++;
|
|
}
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|