-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathft_memccpy.c
31 lines (28 loc) · 1.18 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: vbrazhni <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/30 14:01:50 by vbrazhni #+# #+# */
/* Updated: 2018/06/30 14:01:51 by vbrazhni ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char sym;
unsigned char *d;
unsigned char *s;
sym = (unsigned char)c;
d = (unsigned char *)dst;
s = (unsigned char *)src;
while (n--)
{
*d++ = *s++;
if (*(d - 1) == sym)
return (d);
}
return (NULL);
}