-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
31 lines (28 loc) · 1.22 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eel-orch <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/10/19 02:10:26 by eel-orch #+# #+# */
/* Updated: 2019/11/10 01:34:14 by eel-orch ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
size_t index;
unsigned char *ptr;
unsigned const char *s;
index = -1;
ptr = (unsigned char *)dest;
s = (unsigned const char *)src;
while (++index < n)
{
ptr[index] = s[index];
if (s[index] == (unsigned char)c)
return (dest + index + 1);
}
return (0);
}