-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
33 lines (30 loc) · 1.18 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bwebb <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/22 15:03:05 by bwebb #+# #+# */
/* Updated: 2019/05/30 11:58:51 by bwebb ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *source, int c, size_t n)
{
size_t i;
unsigned char *dst;
unsigned const char *sc;
unsigned char c1;
c1 = c;
i = -1;
dst = dest;
sc = source;
while (++i < n)
{
dst[i] = sc[i];
if (c1 == sc[i])
return (dst + i + 1);
}
return (NULL);
}