libft
Loading...
Searching...
No Matches
ft_memchr.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_memchr.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2022/10/31 14:06:00 by tspoof #+# #+# */
9/* Updated: 2022/11/30 16:48:03 by tspoof ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15void *ft_memchr(const void *s, int c, size_t n)
16{
17 size_t i;
18
19 i = 0;
20 while (i < n)
21 {
22 if (*(unsigned char *)(s + i) == (unsigned char)c)
23 {
24 return ((char *)(s + i));
25 }
26 i++;
27 }
28 return (NULL);
29}
void * ft_memchr(const void *s, int c, size_t n)
Scan memory for a character.
Definition ft_memchr.c:15