-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memchr.c
More file actions
32 lines (29 loc) · 1.14 KB
/
ft_memchr.c
File metadata and controls
32 lines (29 loc) · 1.14 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sel-mars <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/02 10:22:16 by sel-mars #+# #+# */
/* Updated: 2021/11/09 10:59:38 by sel-mars ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *str, int c, size_t n)
{
size_t i;
unsigned char cc;
unsigned char *dst;
i = 0;
cc = (unsigned char) c;
dst = (unsigned char *)str;
while (i < n)
{
if (*dst == cc)
return (dst);
dst++;
i++;
}
return (0);
}