feat: added strdup and putptr

This commit is contained in:
Zoëy Noort 2025-05-31 19:37:36 +02:00
parent 0f35f48c25
commit 2a34720f4d
2 changed files with 32 additions and 0 deletions

19
srcs/ft_strdup.c Normal file
View file

@ -0,0 +1,19 @@
#include "libft.h"
#include <stdlib.h>
char *ft_strdup(const char *s)
{
size_t len = 0;
char *dup;
size_t i;
while (s[len])
len++;
dup = (char *)malloc(len + 1);
if (!dup)
return NULL;
for (i = 0; i < len; i++)
dup[i] = s[i];
dup[len] = '\0';
return (dup);
}