minishell
ft_memchr.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memchr.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: kfujita <kfujita@student.42tokyo.jp> +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2022/04/10 16:51:02 by kfujita #+# #+# */
9
/* Updated: 2022/04/25 23:41:47 by kfujita ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include <stddef.h>
14
#include "
ft_mem.h
"
15
16
void
*
ft_memchr
(
const
void
*s,
int
c,
size_t
n)
17
{
18
unsigned
char
*p_s;
19
unsigned
char
looking_for;
20
21
if
(n == 0)
22
return
(NULL);
23
p_s = (
unsigned
char
*)s;
24
looking_for = (
unsigned
char)c;
25
while
(--n > 0 && *p_s != looking_for)
26
p_s++;
27
if
(*p_s == looking_for)
28
return
(p_s);
29
else
30
return
(NULL);
31
}
ft_mem.h
ft_memchr
void * ft_memchr(const void *s, int c, size_t n)
Definition:
ft_memchr.c:16
libft
ft_mem
ft_memchr.c
Generated by
1.9.1