-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
46 lines (41 loc) · 1.33 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
45
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sde-silv <sde-silv@student.42berlin.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/31 16:52:35 by sde-silv #+# #+# */
/* Updated: 2023/06/12 14:39:08 by sde-silv ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
#include <string.h>
*/
void *ft_memchr(const void *s, int c, size_t n)
{
size_t i;
unsigned char *ptr;
ptr = (unsigned char *)s;
i = 0;
while (i < n)
{
if (*ptr == (unsigned char)c)
return ((void *)ptr);
ptr ++;
i ++;
}
return (NULL);
}
/*
int main(void)
{
char *s;
s = "Hello World!";
write(1, memchr(s, 'W',strlen(s)), 6);
write (1, "\n", 1);
write(1, ft_memchr(s, 'W',strlen(s)), 6);
write (1, "\n", 1);
}
*/