-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
34 lines (31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gwasserf <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/20 17:15:17 by gwasserf #+# #+# */
/* Updated: 2019/06/24 13:00:52 by gwasserf ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
const char *source;
char *destination;
int index;
index = 0;
source = src;
destination = dest;
while (n-- > 0)
{
destination[index] = source[index];
if (source[index] == (char)c)
{
return ((void *)&destination[index + 1]);
}
index++;
}
return (NULL);
}