28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_strdup.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: pbonilla <eirodeis.lepnj@gmail.com> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2020/11/11 18:45:41 by pbonilla #+# #+# */
|
||
|
/* Updated: 2021/01/31 04:55:04 by pbonilla ### ########.fr */
|
||
|
/* */
|
||
|
/* ************************************************************************** */
|
||
|
|
||
|
#include "libft.h"
|
||
|
|
||
|
char *ft_strdup(const char *s)
|
||
|
{
|
||
|
char *dup;
|
||
|
int i;
|
||
|
|
||
|
if (!(dup = malloc(sizeof(char) * ft_strlen(s) + 1)))
|
||
|
return (NULL);
|
||
|
i = -1;
|
||
|
while (s[++i])
|
||
|
dup[i] = s[i];
|
||
|
dup[i] = 0;
|
||
|
return (dup);
|
||
|
}
|