-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memchr.c
31 lines (27 loc) · 1.24 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bnidia <bnidia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/12 07:07:25 by bnidia #+# #+# */
/* Updated: 2021/10/29 01:41:50 by bnidia ### ########.fr */
/* */
/* ************************************************************************** */
/* ft_memchr
** Scans the initial len bytes of b for the first instance of c
** Return Value
** A pointer to the matching byte or NULL if the character does
** not occur in the given memory area
*/
#include "libft.h"
void *ft_memchr(const void *b, int c, size_t len)
{
char *str;
str = (char *)b;
while (len--)
if (*str++ == (char)c)
return (str - 1);
return (NULL);
}