mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-05-14 00:08:47 +02:00
「✨」 feat(libft): added a very cool feature !
This commit is contained in:
31
libft/str/ft_strtrim.c
Normal file
31
libft/str/ft_strtrim.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtrim.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/11/11 00:37:37 by adjoly #+# #+# */
|
||||
/* Updated: 2024/02/04 14:48:45 by adjoly ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../libft.h"
|
||||
|
||||
char *ft_strtrim(char const *s1, char const *set)
|
||||
{
|
||||
int i;
|
||||
int j;
|
||||
char *result;
|
||||
|
||||
i = 0;
|
||||
if (s1 == NULL || set == NULL)
|
||||
return (NULL);
|
||||
j = ft_strlen(s1);
|
||||
while (ft_strchr(set, s1[i]) != 0)
|
||||
i++;
|
||||
while (ft_strrchr(set, s1[j]) != 0)
|
||||
j--;
|
||||
result = ft_substr(s1, i, (j - i) + 1);
|
||||
return (result);
|
||||
}
|
Reference in New Issue
Block a user