-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strtrim.c
More file actions
40 lines (33 loc) · 1.33 KB
/
ft_strtrim.c
File metadata and controls
40 lines (33 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/19 19:02:37 by marvin #+# #+# */
/* Updated: 2022/06/20 18:54:40 by aettouha ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_strtrim(char const *s1, char const *set)
{
size_t i;
if (s1 == NULL || set == NULL)
return (NULL);
while (*s1 && ft_strchr(set, *s1))
s1++;
i = ft_strlen(s1);
while (i && ft_strchr(set, s1[i]))
i--;
return (ft_substr(s1, 0, i + 1));
}
/*int main()
{
char a[50];
char b[50];
strcpy(a, "holaqholaquetalqhola");
strcpy(b, "hola");
printf("Before: %s\n", a);
printf("After: %s", ft_strtrim(a, b));
}*/