ft_memchr

nawkim·2021년 5월 26일
0

libft

목록 보기
21/44

1. 프로토타입

void	*ft_memchr(const void *s, int c, size_t n)
  • 헤더
#include <string.h>
  • 형태
void	*memchr(const void *s, int c, size_t n)

2. 용도

3. 리턴값

4. 코드 구현

#include "libft.h"

void	*ft_memchr(const void *s, int c, size_t n)
{
	size_t			t;
	unsigned char	*ss;
	unsigned char	cc;

	t = 0;
	ss = (unsigned char *)s;
	cc = (unsigned char)c;
	while (t < n)
	{
		if (ss[t] == cc)
			return ((void *)(ss + t));
		t++;
	}
	return (NULL);
}

5. 코드 설명

profile
공부 기록.

0개의 댓글