1
0
libft_new/ft_memchr.c

28 lines
1.1 KiB
C
Raw Normal View History

2023-11-05 15:12:25 +01:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/05 14:52:53 by adjoly #+# #+# */
2023-11-09 18:28:02 +01:00
/* Updated: 2023/11/09 14:27:32 by adjoly ### ########.fr */
2023-11-05 15:12:25 +01:00
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memchr(const void *s, int c, size_t n)
{
2023-11-08 12:46:30 +01:00
size_t i;
2023-11-06 17:25:35 +01:00
i = 0;
2023-11-09 18:28:02 +01:00
while (i < n)
2023-11-06 17:25:35 +01:00
{
2023-11-09 18:28:02 +01:00
if (((unsigned char *)s)[i] == (unsigned char)c)
return (((void *)s + i));
2023-11-06 17:25:35 +01:00
i++;
}
return (NULL);
2023-11-05 15:12:25 +01:00
}