-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
31 lines (28 loc) · 1.19 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: edelangh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/03 15:54:43 by edelangh #+# #+# */
/* Updated: 2014/11/11 11:22:31 by edelangh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *s1;
unsigned const char *s2;
int i;
s1 = (unsigned char*)dst;
s2 = (unsigned const char*)src;
i = 0;
while (n--)
{
s1[i] = s2[i];
if (s2[i++] == (unsigned char)c)
return (dst + i);
}
return (NULL);
}