-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
30 lines (27 loc) · 1.21 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: ssacrist <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/12/16 12:39:50 by ssacrist #+# #+# */
/* Updated: 2019/12/23 10:05:44 by ssacrist ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *str_tosearch, int char_tofind, size_t how_many)
{
unsigned char *str;
size_t counter;
str = (unsigned char *)str_tosearch;
counter = 0;
while (counter < how_many)
{
if (*(str + counter) == (unsigned char)char_tofind)
return (str + counter);
else
++counter;
}
return (NULL);
}