-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
35 lines (32 loc) · 1.23 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: chrhuang <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/07 11:32:26 by chrhuang #+# #+# */
/* Updated: 2018/11/12 14:53:22 by chrhuang ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
unsigned char *tmp;
unsigned char *tmp1;
tmp = (unsigned char *)dest;
tmp1 = (unsigned char *)src;
while (n != 0)
{
*tmp = *tmp1;
if (*tmp == (unsigned char)c)
{
tmp = tmp + 1;
return (tmp);
}
tmp = tmp + 1;
tmp1 = tmp1 + 1;
n = n - 1;
}
return (NULL);
}