-
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: ahel-bah <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/08 12:42:12 by ahel-bah #+# #+# */
/* Updated: 2021/11/15 10:24:16 by ahel-bah ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
unsigned char *casts;
unsigned char castc;
i = 0;
casts = (unsigned char *)s;
castc = (unsigned char)c;
while (i < n)
{
if (casts[i] == castc)
{
return (&casts[i]);
}
i++;
}
return (0);
}