-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strtrim.c
29 lines (26 loc) · 1.17 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
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juhagon <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/04 13:25:08 by juhagon #+# #+# */
/* Updated: 2022/01/25 09:57:37 by juhagon ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int len;
char *rtn;
if (!s1 || !set)
return (0);
while (*s1 && ft_strchr(set, *s1))
s1++;
len = ft_strlen(s1);
while (len && ft_strchr(set, s1[len]))
len--;
rtn = ft_substr((char *)s1, 0, len + 1);
return (rtn);
}