42_libft/ft_strdup.c
Camille Chauvet 1d0f0b1901 m
2022-09-27 16:29:23 +02:00

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/09/27 16:07:00 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *strdup(const char *s)
{
char *in;
char *out;
size_t i;
in = (char *) s;
out = malloc(sizeof(char) * (ft_strlen(in) + 1));
i = 0;
while (in[i])
{
out[i] = in[i];
i++;
}
out[i] = 0;
return (out);
}