-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
44 lines (36 loc) · 1.27 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
32
33
34
35
36
37
38
39
40
41
42
43
44
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+
+:+ */
/* By: marvin <marvin@student.42.fr> +#+ +:+
+#+ */
/* +#+#+#+#+#+
+#+ */
/* Created: 2023/09/13 12:52:39 by marvin #+# #+# */
/* Updated: 2023/09/13 12:52:39 by marvin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
const unsigned char *ptr_s;
ptr_s = s;
while (n > 0)
{
if (*ptr_s == (unsigned char)c)
return ((void *)ptr_s);
ptr_s++;
n--;
}
return (NULL);
}
// int main(void)
// {
// char *str = "botte de foin";
// int c = 'z';
// size_t i = 13;
// printf("%p\n", memchr(str, c, i));
// return (0);
// }