/ fdf / fdf / libft / ft_memchr.c
ft_memchr.c
 1  /* ************************************************************************** */
 2  /*                                                                            */
 3  /*                                                        :::      ::::::::   */
 4  /*   ft_memchr.c                                        :+:      :+:    :+:   */
 5  /*                                                    +:+ +:+         +:+     */
 6  /*   By: gychoi <marvin@42.fr>                      +#+  +:+       +#+        */
 7  /*                                                +#+#+#+#+#+   +#+           */
 8  /*   Created: 2022/07/08 19:26:05 by gychoi            #+#    #+#             */
 9  /*   Updated: 2022/07/16 15:35:58 by gychoi           ###   ########.fr       */
10  /*                                                                            */
11  /* ************************************************************************** */
12  
13  #include "libft.h"
14  
15  void	*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  			return ((void *)s + i);
24  		i++;
25  	}
26  	return (NULL);
27  }