[C] memchr / memchr.c / memchr in c

2022. 7. 25. 17:27🧑🏻‍💻/C & C++

man memchr

 

void	*memchr(const void *s, int c, size_t n)
{
	unsigned char	*s_dst;
	unsigned char	find;

	find = c;
	s_dst = (unsigned char *)s;
	while (n--)
	{
		if (*s_dst == find)
			return (s_dst);
		s_dst++;
	}
	return (0);
}