-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memchr.c
30 lines (27 loc) · 1.13 KB
/
ft_memchr.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmncube <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/28 11:16:37 by nmncube #+# #+# */
/* Updated: 2019/06/26 13:15:00 by nmncube ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *s1;
unsigned char c1;
s1 = (unsigned char *)s;
c1 = (unsigned char)c;
while (n > 0 && *s1 != c1)
{
n--;
s1++;
}
if (n == 0)
return (NULL);
return ((void *)s1);
}