-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
27 lines (24 loc) · 1.19 KB
/
ft_strtrim.c
File metadata and controls
27 lines (24 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bmetehri <bmetehri@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/28 21:37:39 by bmetehri #+# #+# */
/* Updated: 2023/01/03 16:17:54 by bmetehri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
int length;
int start;
start = 0;
while (ft_strchr(set, s1[start]) && s1[start] != '\0')
start++;
length = ft_strlen(s1) - 1;
while (ft_strchr(set, s1[length]) && s1[length])
length--;
return (ft_substr(s1, start, length - start + 1));
}