-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strtrim.c
44 lines (38 loc) · 1.37 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: julmuntz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/21 22:17:55 by julmuntz #+# #+# */
/* Updated: 2022/06/02 22:16:31 by julmuntz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *str, char const *set)
{
size_t start;
size_t end;
if (str == NULL)
return (NULL);
start = 0;
while (ft_strchr(set, str[start]))
start++;
end = ft_strlen(str);
while (ft_strrchr(set, str[end]))
end--;
return (ft_substr(str, start, end - start + 1));
}
/*
#include <stdio.h>
int main(int arc, char **arv)
{
char *str;
if (arc == 3)
{
str = ft_strtrim(arv[1], arv[2]);
printf("%s\n", str);
}
}
*/