-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
33 lines (30 loc) · 1.15 KB
/
Copy pathft_strtrim.c
File metadata and controls
33 lines (30 loc) · 1.15 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: astoll <astoll@student.42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/31 13:11:48 by astoll #+# #+# */
/* Updated: 2023/10/31 13:22:47 by astoll ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
size_t len;
if (!s1 || !set)
{
return (0);
}
while (*s1 && ft_strchr(set, *s1))
{
s1++;
}
len = ft_strlen(s1);
while (len && ft_strchr(set, s1[len]))
{
len--;
}
return (ft_substr(s1, 0, len + 1));
}