Files
SortStack/lib/libft/ft_strtrim.c
T
HexPloR 4c83562ca9 ez
2024-06-24 00:05:59 +02:00

28 lines
1.1 KiB
C
Executable File

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hexplor <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/16 13:48:16 by hexplor #+# #+# */
/* Updated: 2023/11/29 13:09:29 by hexplor ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int i;
int j;
i = 0;
j = ft_strlen(s1) - 1;
while (s1[i] && ft_strchr(set, s1[i]))
i++;
while (s1[j] && ft_strchr(set, s1[j]))
j--;
return (ft_substr(s1, i, (j - i + 1)));
}