-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abassibe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/21 05:19:20 by abassibe #+# #+# */
/* Updated: 2018/03/14 01:39:58 by abassibe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned int i;
unsigned char *s1;
unsigned char *s2;
unsigned char t;
s1 = (unsigned char *)src;
s2 = (unsigned char *)dst;
t = (unsigned char)c;
i = 0;
while (i < n)
{
if ((*s2++ = *s1++) == t)
return (s2);
i++;
}
return (NULL);
}