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