-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
26 lines (22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dghonyan <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/13 11:46:29 by dghonyan #+# #+# */
/* Updated: 2022/05/08 18:49:01 by adashyan ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
void *ft_memchr(const void *s, int c, size_t n)
{
if (n == 0)
return (NULL);
while (--n && *(unsigned char *)s != (unsigned char)c)
s++;
if (*(unsigned char *)s != (unsigned char)c)
return (NULL);
return (s);
}