Archived
1
0

wip_parsing

This commit is contained in:
Maelys
2024-09-10 16:27:06 +02:00
commit c671539661
62 changed files with 1863 additions and 0 deletions

31
libft/str/ft_strtrim.c Normal file
View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: madumerg <madumerg@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/06 11:33:52 by madumerg #+# #+# */
/* Updated: 2023/11/07 17:51:00 by madumerg ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
size_t start;
size_t len;
char *str;
if (!s1)
return (NULL);
len = ft_strlen(s1);
start = 0;
while (ft_strchr(set, s1[start]) != 0)
start++;
while (ft_strrchr(set, s1[len]) != 0)
len--;
str = ft_substr(s1, start, (len - start) + 1);
return (str);
}