-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
31 lines (28 loc) · 1.23 KB
/
ft_memccpy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hcastanh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/04/25 23:31:29 by hcastanh #+# #+# */
/* Updated: 2020/05/08 00:19:41 by hcastanh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dst_p;
unsigned char *src_p;
if (n)
{
dst_p = (unsigned char *)dst;
src_p = (unsigned char *)src;
if ((*dst_p++ = *src_p++) == (unsigned char)c)
return (dst_p);
while (--n != 0)
if ((*dst_p++ = *src_p++) == c)
return (dst_p);
}
return (0);
}