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

37
lib/libft/ft_strtrim.c Normal file
View File

@@ -0,0 +1,37 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/04 20:21:56 by aortigos #+# #+# */
/* Updated: 2023/10/19 16:58:30 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
size_t len;
char *x;
if (!s1 || !set)
return (NULL);
while (ft_strchr(set, *s1) && *s1 != '\0')
{
s1++;
}
if (*s1 == '\0')
{
return (ft_strdup(""));
}
len = ft_strlen(s1);
while (ft_strchr(set, s1[len]))
{
len--;
}
x = ft_substr(s1, 0, len + 1);
return (x);
}