makefile organise
This commit is contained in:
59
srcs/part2/ft_strtrim.c
Normal file
59
srcs/part2/ft_strtrim.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strtrim.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2019/11/19 17:26:06 by hulamy #+# #+# */
|
||||
/* Updated: 2019/11/19 18:15:32 by hulamy ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
/*
|
||||
** create a copy of s without the firsts and lasts empty characters
|
||||
*/
|
||||
|
||||
/*
|
||||
** #include <libc.h>
|
||||
**
|
||||
** char *ft_strtrim(char const *s1, char const *set);
|
||||
**
|
||||
** int main(int ac, char **av)
|
||||
** {
|
||||
** if (ac == 3)
|
||||
** printf("%s\n",ft_strtrim(av[1], av[2]));
|
||||
**
|
||||
** return (0);
|
||||
** }
|
||||
*/
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
char *ft_strtrim(char const *s1, char const *set)
|
||||
{
|
||||
int len;
|
||||
char *str;
|
||||
(void)set;
|
||||
|
||||
if (!s1)
|
||||
return (NULL);
|
||||
while (s1[0] && ft_strchr(set, s1[0]))
|
||||
s1++;
|
||||
len = ft_strlen(s1) - 1;
|
||||
while (len >= 0 && ft_strchr(set, s1[len]))
|
||||
len--;
|
||||
len++;
|
||||
if (!(str = ft_strsub(s1, 0, len)))
|
||||
return (NULL);
|
||||
return (str);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user