32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: dgaillet <dgaillet@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/11/05 19:31:29 by dgaillet #+# #+# */
|
|
/* Updated: 2025/11/06 10:07:22 by dgaillet ### ########lyon.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *s)
|
|
{
|
|
char *dest;
|
|
int i;
|
|
|
|
dest = malloc(sizeof(char) *(ft_strlen(s) + 1));
|
|
if (!dest)
|
|
return (NULL);
|
|
i = 0;
|
|
while (s[i])
|
|
{
|
|
dest[i] = s[i];
|
|
i++;
|
|
}
|
|
dest[i] = '\0';
|
|
return (dest);
|
|
}
|