-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_endtrim.c
37 lines (33 loc) · 1.3 KB
/
ft_endtrim.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
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_endtrim.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/18 20:52:34 by mbutt #+# #+# */
/* Updated: 2019/03/25 12:31:49 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
/*
** Description - Takes a string with delimiter and removes delimiter from the
** end and gives the index of the last character in the string that is not a
** delimiter
*/
#include "libft.h"
int ft_endtrim(char const *s, char c)
{
int b;
b = ft_strlen(s) - 1;
while (s[b] == c)
b--;
return (b);
}
/*
** int main (void)
** {
** char *string = "***123********";
** char c = '*';
** printf("%d", ft_endtrim(string, c));
** }
*/