-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memchr.c
More file actions
33 lines (31 loc) · 1.19 KB
/
Copy pathft_memchr.c
File metadata and controls
33 lines (31 loc) · 1.19 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
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: yelallam <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/01 20:49:10 by yelallam #+# #+# */
/* Updated: 2025/11/01 21:37:45 by yelallam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned const char *ptr;
size_t i;
ptr = s;
i = 0;
while (i < n)
{
if (ptr[i] == (unsigned char) c)
return ((void *) &ptr[i]);
i++;
}
return (NULL);
}
/*int main()
{
char lp[] = "sjofA";
printf("%p\n", ft_memchr(lp, 111, 4));
}*/