-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strtrim.c
28 lines (25 loc) · 1.14 KB
/
ft_strtrim.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bcaffere <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/05/05 16:07:41 by bcaffere #+# #+# */
/* Updated: 2021/05/05 16:30:00 by bcaffere ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
char *str;
size_t i;
while (*s1 && ft_strchr(set, *s1))
s1++;
i = ft_strlen(s1);
while (*s1 && ft_strrchr(set, s1[i]))
i--;
str = ft_substr(s1, 0, i + 1);
return (str);
}