-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strtrim.c
27 lines (24 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kpetrosy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/01/27 19:39:07 by kpetrosy #+# #+# */
/* Updated: 2021/01/27 19:42:08 by kpetrosy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
size_t size_s1;
if (!s1 || !set)
return (NULL);
while (ft_strchr(set, *s1) && *s1 != '\0')
s1++;
size_s1 = ft_strlen((char *)s1);
while (ft_strchr(set, s1[size_s1]) && size_s1 != 0)
size_s1--;
return (ft_substr((char *)s1, 0, size_s1 + 1));
}