aboutsummaryrefslogtreecommitdiff
path: root/ft_memchr.c
blob: 662a6c78d477b4445730e8ce6ce3a6cc5f670398 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string.h>

void    *ft_memchr(const void *s, int c, size_t n)
{
    size_t          i;
    unsigned char   *uc_s;

    uc_s = (unsigned char*)s;
    i = 0;
    while (i < n)
    {
        if (uc_s[i] == (unsigned char)c)
            return (uc_s + i);
        i++;
    }
    return (NULL);
}