31 lines
1.1 KiB
C
31 lines
1.1 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: rzy <ry@student.42angouleme.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2026/08/24 01:09:08 by rzy #+# #+# */
|
|
/* Updated: 2026/08/24 01:09:25 by rzy ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *s)
|
|
{
|
|
int i;
|
|
char *dup;
|
|
|
|
dup = malloc(sizeof (char) * (ft_strlen(s) + 1));
|
|
if (dup == NULL)
|
|
return (NULL);
|
|
i = 0;
|
|
while (s[i])
|
|
{
|
|
dup[i] = s[i];
|
|
++i;
|
|
}
|
|
dup[i] = 0;
|
|
return (dup);
|
|
}
|