Archived
1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
libft/ft_strdup.c
2023-11-04 18:37:19 +01:00

34 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 22:57:39 by adjoly #+# #+# */
/* Updated: 2023/11/04 14:40:17 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s)
{
int i;
char *result;
int len;
i = 0;
len = ft_strlen(s);
result = malloc(sizeof(char) * (len + 1));
if (result == NULL)
return (NULL);
while (s[i])
{
result[i] = s[i];
i++;
}
result[i] = '\0';
return (result);
}