blob: f4b4d38bd5d2656f403a06a745e741fb3fb1d24b (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:07:11 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:07:11 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stddef.h>
long
ft_strlchr(const char *s, int c)
{
const size_t len = ft_strlen(s);
const size_t rem = ft_strlen(ft_strchr(s, c));
if (len - rem >= ft_strlen(s))
return (-1);
return (len - rem);
}
|