blob: b160ca5953655afbd80713ba1e11923089b02fbc (
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memlchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbousset <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:06:42 by rbousset #+# #+# */
/* Updated: 2020/02/14 17:06:42 by rbousset ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <libft.h>
#include <stddef.h>
long ft_memlchr(const void *s, int c, size_t n)
{
const size_t len = ft_strlen((const char *)s);
const size_t rem = ft_strlen((const char *)ft_memchr(s, c, n));
if (len - rem >= ft_strlen((const char *)s))
return (-1);
return (len - rem);
}
|