Libft and ftprintf added

This commit is contained in:
Angel Ortigosa Perez
2025-11-15 10:31:47 +01:00
parent 5c40a00540
commit a4c1881930
54 changed files with 1809 additions and 105 deletions

29
lib/libft/ft_strdup.c Normal file
View File

@@ -0,0 +1,29 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strdup.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/27 21:04:50 by aortigos #+# #+# */
/* Updated: 2023/10/22 11:15:45 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strdup(const char *s1)
{
char *s2;
size_t i;
i = ft_strlen(s1);
s2 = (char *)malloc(i + 1);
if (!(s2))
{
return (NULL);
}
ft_memcpy(s2, s1, i);
s2[i] = '\0';
return (s2);
}