init
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* 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);
|
||||
}
|
||||
Reference in New Issue
Block a user