Skip to content

Commit dd52068

Browse files
authored
Update ft_strtrim.c
1 parent df5e16b commit dd52068

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

Libft/ft_str/ft_strtrim.c

+3-8
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,9 @@ char *ft_strtrim(const char *s1, const char *set)
2828
break ;
2929
ln++;
3030
}
31-
cnt = 0;
32-
while (s1[cnt + 1])
33-
cnt++;
34-
while (cnt >= 0)
35-
{
36-
if (ft_strchr(set, s1[cnt]) != 0)
31+
cnt = ft_strlen(s1);
32+
while (--cnt)
33+
if (!ft_strchr(set, s1[cnt]))
3734
break ;
38-
cnt--;
39-
}
4035
return (ft_strcpyl((char *) s1 + ln, (cnt + 1) - ln));
4136
}

0 commit comments

Comments
 (0)