-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_strrstrip.c
executable file
·32 lines (29 loc) · 1.25 KB
/
ft_strrstrip.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrstrip.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: akharrou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/19 10:42:43 by akharrou #+# #+# */
/* Updated: 2019/05/19 10:42:44 by akharrou ### ########.fr */
/* */
/* ************************************************************************** */
#include "../Includes/ctype_42.h"
#include "../Includes/stdlib_42.h"
#include "../Includes/string_42.h"
char *ft_strrstrip(char const *s, char *charset)
{
int last;
char *rstripped;
if (s)
{
last = ft_strlen(s) - 1;
while (last >= 0 && ft_ischarset(s[last], charset))
--last;
rstripped = ft_strndup(s, last + 1);
free((void *)s);
return (rstripped);
}
return (NULL);
}