-
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.14 KB
/
ft_strtrim.c
File metadata and controls
29 lines (26 loc) · 1.14 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: framos-p <framos-p@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/26 16:01:03 by framos-p #+# #+# */
/* Updated: 2022/05/28 17:09:43 by framos-p ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int i;
int j;
char *new;
i = 0;
while (s1[i] && ft_strchr(set, s1[i]))
i++;
j = ft_strlen(s1);
while (s1[i] && ft_strchr(set, s1[j - 1]))
j--;
new = ft_substr(s1, i, j - i);
return (new);
}