-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strtrim.c
29 lines (26 loc) · 1.19 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: hykang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/01/25 16:05:21 by hykang #+# #+# */
/* Updated: 2022/01/25 17:31:56 by hykang ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int start;
int end;
char *res;
start = 0;
while (s1[start] && ft_strchr(set, s1[start]))
start++;
end = ft_strlen(s1);
while (ft_strchr(set, s1[end - 1]) && end > start)
end--;
res = ft_substr(s1, start, (end - start));
return (res);
}