-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
29 lines (26 loc) · 1.15 KB
/
ft_strtrim.c
File metadata and controls
29 lines (26 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hulefevr <hulefevr@student.42nice.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/04/22 11:08:26 by hulefevr #+# #+# */
/* Updated: 2024/04/22 12:57:10 by hulefevr ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
char *d;
size_t l;
if (!s1 || !set)
return (NULL);
while (*s1 && ft_strchr(set, *s1))
s1++;
l = ft_strlen(s1);
while (ft_strchr(set, s1[l]) && l)
l--;
d = ft_substr((char *)s1, 0, l + 1);
return (d);
}