-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memchr.c
More file actions
37 lines (32 loc) · 1.29 KB
/
ft_memchr.c
File metadata and controls
37 lines (32 loc) · 1.29 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sanmetol <sanmetol@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/20 18:18:59 by sanmetol #+# #+# */
/* Updated: 2023/04/27 17:46:13 by sanmetol ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
const unsigned char *ptr = s;
while (n--)
{
if (*ptr == (unsigned char)c)
return ((void *)ptr);
ptr++;
}
return (0);
}
/* int main(void)
{
/////MINE/////
char *s = "hola";
printf("%s%s%s", "nu", ft_memchr(s, 'o', 5), "ll");
//////ORIGINAL/////
char *s_o = "hola";
printf("\nORIGINAL:\n%s%s%s", "nu", memchr(s_o, 'o', 5), "ll");
} */