-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
33 lines (30 loc) · 1.27 KB
/
ft_memccpy.c
File metadata and controls
33 lines (30 loc) · 1.27 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: xvan-ham <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/08 19:57:07 by xvan-ham #+# #+# */
/* Updated: 2019/11/09 14:07:04 by xvan-ham ### ########.fr */
/* */
/* ************************************************************************** */
#include "string.h"
void *ft_memccpy(void *restrict dst,
const void *restrict src, int c, size_t n)
{
unsigned char *csrc;
unsigned char *cdst;
csrc = (unsigned char *)src;
cdst = (unsigned char *)dst;
if (!n)
return (0);
while (n-- > 0 && *csrc != (unsigned char)c)
*(cdst++) = *(csrc++);
if (*csrc == (unsigned char)c)
{
*(cdst++) = *(csrc++);
return ((void *)cdst);
}
return (0);
}