mirror of
https://github.com/Ladebeze66/libft.git
synced 2025-12-13 04:36:55 +01:00
32 lines
1.1 KiB
C
Executable File
32 lines
1.1 KiB
C
Executable File
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_strdup.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/02/11 18:40:02 by fgras-ca #+# #+# */
|
|
/* Updated: 2023/12/10 12:25:07 by fgras-ca ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
char *ft_strdup(const char *s)
|
|
{
|
|
char *str;
|
|
size_t i;
|
|
|
|
str = (char *)malloc(sizeof(char) * (ft_strlen(s) + 1));
|
|
if (!str)
|
|
return (NULL);
|
|
i = 0;
|
|
while (s[i])
|
|
{
|
|
str[i] = s[i];
|
|
i++;
|
|
}
|
|
str[i] = 0;
|
|
return (str);
|
|
}
|