Libft aortigos
This commit is contained in:
29
ft_memchr.c
Normal file
29
ft_memchr.c
Normal file
@@ -0,0 +1,29 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_memchr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/09/22 19:00:54 by aortigos #+# #+# */
|
||||
/* Updated: 2023/10/26 07:41:42 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memchr(const void *s, int c, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
i = 0;
|
||||
while (i < n)
|
||||
{
|
||||
if (((const unsigned char *)s)[i] == (unsigned char)c)
|
||||
{
|
||||
return ((void *)&((const unsigned char *)s)[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return (NULL);
|
||||
}
|
||||
Reference in New Issue
Block a user