32 lines
1.1 KiB
C
32 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/09/27 16:00:49 by cchauvet #+# #+# */
|
|
/* Updated: 2022/10/06 16:53:02 by cchauvet ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libftprintf.h"
|
|
|
|
char *ft_strdup(char *s)
|
|
{
|
|
char *out;
|
|
size_t i;
|
|
|
|
out = malloc((ft_strlen(s) + 1) * sizeof(char));
|
|
if (out == NULL)
|
|
return (NULL);
|
|
i = 0;
|
|
while (s[i])
|
|
{
|
|
out[i] = s[i];
|
|
i++;
|
|
}
|
|
out[i] = 0;
|
|
return (out);
|
|
}
|