-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
33 lines (30 loc) · 1.16 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
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atweek <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/02 18:36:57 by ramil #+# #+# */
/* Updated: 2020/11/08 04:30:13 by atweek ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *arr, int c, size_t n)
{
size_t i;
unsigned char *ptr;
unsigned char new_c;
i = 0;
ptr = (unsigned char *)arr;
new_c = (unsigned char)c;
while (i < n)
{
if (ptr[i] == new_c)
{
return (ptr + i);
}
i++;
}
return (NULL);
}