blob: 275a797bb2cee5a7300cb4ec3a69b6a8bca29358 (
plain)
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
|
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: joelecle <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/14 17:06:41 by joelecle #+# #+# */
/* Updated: 2020/02/14 17:06:41 by joelecle ### ########lyon.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
#include <stdio.h>
void
*ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dst_ptr;
const unsigned char *src_ptr;
dst_ptr = (unsigned char*)dst;
src_ptr = (unsigned char*)src;
if (!*dst_ptr && !*src_ptr && n)
return (NULL);
if (n)
{
while (n)
{
if ((*dst_ptr++ = *src_ptr++) == (unsigned char)c)
return (dst_ptr);
n--;
}
}
return (NULL);
}
|