-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
41 lines (37 loc) · 1.28 KB
/
ft_strtrim.c
File metadata and controls
41 lines (37 loc) · 1.28 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
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ulyildiz <ulyildiz@student.42kocaeli.co +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/10/12 23:35:20 by ulyildiz #+# #+# */
/* Updated: 2023/10/18 10:38:25 by ulyildiz ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int ft_isit(char const *set, int c)
{
while (*set != '\0')
{
if (*set == c)
return (1);
set++;
}
return (0);
}
char *ft_strtrim(char const *s1, char const *set)
{
char *arr;
int len;
len = ft_strlen(s1);
while (*s1 != '\0' && ft_isit(set, *s1))
{
s1++;
len--;
}
while (len != 0 && ft_isit(set, s1[len - 1]))
len--;
arr = ft_substr(s1, 0, len);
return (arr);
}