-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
35 lines (32 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
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: npimenof <npimenof@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/17 10:43:07 by npimenof #+# #+# */
/* Updated: 2019/10/23 17:33:36 by npimenof ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *a;
unsigned char *b;
size_t i;
a = (unsigned char *)dst;
b = (unsigned char *)src;
i = 0;
while (i < n)
{
if (b[i] == (unsigned char)c)
{
a[i] = b[i];
return (dst + i + 1);
}
a[i] = b[i];
i++;
}
return (NULL);
}