-
Notifications
You must be signed in to change notification settings - Fork 0
/
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: bpezeshk <bpezeshk@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/17 14:09:37 by bpezeshk #+# #+# */
/* Updated: 2017/01/19 13:06:08 by bpezeshk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dp;
const unsigned char *sp;
dp = (unsigned char *)dst;
sp = (const unsigned char *)src;
c = (unsigned char)c;
while (n)
{
*dp++ = *sp;
if (*sp++ == c)
return ((void *)dp);
n--;
}
return (NULL);
}