-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
31 lines (28 loc) · 1.2 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: jode-vri <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/09/06 22:10:17 by jode-vri #+# #+# */
/* Updated: 2020/09/17 17:46:23 by jode-vri ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
size_t i;
unsigned char *u_dst;
unsigned char *u_src;
u_dst = (unsigned char *)dst;
u_src = (unsigned char *)src;
i = -1;
while (++i < n)
{
u_dst[i] = u_src[i];
if (u_dst[i] == (unsigned char)c)
return (dst + i + 1);
}
return (NULL);
}