-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memchr.c
More file actions
39 lines (36 loc) · 1.25 KB
/
ft_memchr.c
File metadata and controls
39 lines (36 loc) · 1.25 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
34
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sudaniel <sudaniel@student.42heilbronn.de +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/10 09:56:50 by sudaniel #+# #+# */
/* Updated: 2024/10/12 12:01:03 by sudaniel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *p;
unsigned char ch;
p = (unsigned char *)s;
ch = (unsigned char) c;
while (n--)
{
if (*p == ch)
return ((void *)p);
p++;
}
return (NULL);
}
/*
int main(void)
{
char *s = "REx";
char *p = ft_memchr(s, 'R', 3);
char *p1 = memchr(s, 'R', 3);
printf("%c\n%c\n", *p, *p1);
return (0);
}
*/