-
Notifications
You must be signed in to change notification settings - Fork 1
/
ft_memchr.c
31 lines (28 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sel-mlil <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/23 02:10:28 by sel-mlil #+# #+# */
/* Updated: 2024/10/23 02:11:40 by sel-mlil ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char _c;
const unsigned char *_s;
size_t i;
i = 0;
_c = (unsigned char)c;
_s = (const unsigned char *)s;
while (i < n)
{
if (_s[i] == _c)
return ((void *)_s + i);
i++;
}
return (NULL);
}