-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
40 lines (37 loc) · 1.24 KB
/
ft_memccpy.c
File metadata and controls
40 lines (37 loc) · 1.24 KB
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
36
37
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jagarcia <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 03:33:54 by jagarcia #+# #+# */
/* Updated: 2017/11/10 22:24:33 by jagarcia ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
char *dstcpy;
const char *srccpy;
char c2;
dstcpy = (char *)dst;
srccpy = (const char *)src;
c2 = c;
if (n != 0)
{
while (n > 0)
{
*dstcpy = *srccpy;
if (*srccpy == c2)
{
dstcpy++;
return (dstcpy);
}
dstcpy++;
srccpy++;
n--;
}
}
return (NULL);
}