-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memchr.c
More file actions
39 lines (35 loc) · 1.34 KB
/
ft_memchr.c
File metadata and controls
39 lines (35 loc) · 1.34 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: bhielsch <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/05 10:54:37 by bhielsch #+# #+# */
/* Updated: 2022/10/14 16:46:14 by bhielsch ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include <stdio.h>
void *ft_memchr(const void *s, int c, size_t n)
{
unsigned char *str;
size_t i;
i = 0;
str = (unsigned char *)s;
while (i != n)
{
if (str[i] == (unsigned char) c)
return ((unsigned char *)s + i);
i++;
}
return (NULL);
}
// int main()
// {
// const char s[] = "/|\x12\xff\x09\x42\042\42|\\";
// int c = '\xde';
// int n = 10;
// printf("Mine %p \n", ft_memchr(s, c, n));
// printf("OG %p \n", memchr(s, c, n));
// }