-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
executable file
·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: ioleksiu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 18:33:51 by ioleksiu #+# #+# */
/* Updated: 2016/12/07 19:02:58 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *dstt;
unsigned char *srcc;
size_t i;
dstt = (unsigned char*)dst;
srcc = (unsigned char*)src;
i = 0;
while (i < n)
{
if (srcc[i] == (unsigned char)c)
{
dstt[i] = srcc[i];
return (dst + i + 1);
}
dstt[i] = srcc[i];
i++;
}
return (NULL);
}