-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathft_strtrim.c
More file actions
62 lines (56 loc) · 1.54 KB
/
Copy pathft_strtrim.c
File metadata and controls
62 lines (56 loc) · 1.54 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jperpect <jperpect@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/03 06:15:29 by jperpect #+# #+# */
/* Updated: 2024/05/03 06:15:32 by jperpect ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
static int end_string(char const *s1, char const *set)
{
int cont;
int tras;
tras = ft_strlen(s1) - 1;
cont = 0;
while (set[cont] != '\0')
{
while (s1[tras] == set[cont])
{
tras--;
cont = 0;
}
cont++;
}
return (tras);
}
char *ft_strtrim(char const *s1, char const *set)
{
int cont;
int conts;
int tras;
cont = 0;
conts = 0;
while (set[cont] != '\0')
{
while (s1[conts] == set[cont])
{
conts++;
cont = 0;
}
cont++;
}
tras = end_string(s1, set);
return (ft_substr(s1, conts, tras - conts + 1));
}
/*
int main(int ac,char **av)
{
char *ok;
ok = ft_strtrim("oooooslavaooos","os");
ft_putstr_fd(ok,1);
free(ok);
}/*/