-
Notifications
You must be signed in to change notification settings - Fork 0
/
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: tclement <tclement@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/04/15 10:28:41 by tclement #+# #+# */
/* Updated: 2020/05/11 11:58:52 by tclement ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned const char *ptr;
size_t index;
ptr = (unsigned const char*)s;
index = 0;
while (index < n)
{
if (ptr[index] == (unsigned char)c)
{
return ((char *)s + index);
}
index++;
}
return (NULL);
}