-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathft_memchr.c
More file actions
31 lines (28 loc) · 1.13 KB
/
ft_memchr.c
File metadata and controls
31 lines (28 loc) · 1.13 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wbeets <wbeets@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/03/20 11:56:54 by wbeets #+# #+# */
/* Updated: 2015/03/20 11:56:54 by wbeets ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *ptr;
unsigned char c2;
int i;
i = 0;
c2 = (unsigned char)c;
ptr = (unsigned char *)s;
while (n--)
{
if (ptr[i] == c2)
return (ptr + i);
i++;
}
return (NULL);
}