30 lines
1.1 KiB
C
30 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2015/11/25 14:47:23 by gbrochar #+# #+# */
|
|
/* Updated: 2016/02/29 22:42:42 by gbrochar ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *s1)
|
|
{
|
|
int i;
|
|
char *dest;
|
|
|
|
i = 0;
|
|
dest = malloc(sizeof(dest) * ft_strlen(s1) + 1);
|
|
while (s1[i])
|
|
{
|
|
dest[i] = s1[i];
|
|
i++;
|
|
}
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|