42_cube3D/libftx/libft/ft_strdup.c

32 lines
1.1 KiB
C
Raw Permalink Normal View History

2023-04-26 07:02:44 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 16:00:49 by cchauvet #+# #+# */
/* Updated: 2022/10/04 23:24:11 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
char *out;
size_t i;
out = ft_calloc((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);
}