aboutsummaryrefslogtreecommitdiff
path: root/ft_memchr.c
blob: 934ede813ec93831b7795d44dcfd0dba4cd79898 (plain)
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
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_memchr.c                                        :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/10/07 09:55:31 by cacharle          #+#    #+#             */
/*   Updated: 2019/10/20 12:56:46 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "libft.h"
#include <string.h>

void	*ft_memchr(const void *s, int c, size_t n)
{
	size_t	i;
	t_byte	*cast_s;

	cast_s = (t_byte*)s;
	i = -1;
	while (++i < n)
		if (cast_s[i] == (unsigned char)c)
			return (cast_s + i);
	return (NULL);
}