mirror of
https://github.com/KeyZox71/ft_minipowershell.git
synced 2025-03-16 11:56:49 +01:00
32 lines
1.2 KiB
C
32 lines
1.2 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_memchr.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: mmoussou <mmoussou@student.42angoulem +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2023/11/01 21:52:59 by mmoussou #+# #+# */
|
|
/* Updated: 2023/11/10 17:01:28 by mmoussou ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
void *ft_memchr(const void *s, int c, size_t n)
|
|
{
|
|
size_t i;
|
|
|
|
if (!s || !n)
|
|
return (NULL);
|
|
i = 0;
|
|
while (i < n)
|
|
{
|
|
if (((unsigned char *)s)[i] == (unsigned char)c)
|
|
return ((void *)s + i);
|
|
i++;
|
|
}
|
|
if ((unsigned char)c == 0)
|
|
return ((void *)s + i);
|
|
return (NULL);
|
|
}
|