-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
34 lines (31 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
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbones <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/09 20:26:54 by lbones #+# #+# */
/* Updated: 2021/04/30 18:11:28 by lbones ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dst1;
unsigned char *src1;
dst1 = (unsigned char *)dst;
src1 = (unsigned char *)src;
if (dst == 0 && src == 0)
return (0);
while (n > 0)
{
*dst1 = *src1;
if (*src1 == (unsigned char)c)
return (dst1 + 1);
dst1++;
src1++;
n--;
}
return (NULL);
}