-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
32 lines (29 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
/* ************************************************************************** */
/* */
/* :::::::: */
/* ft_memccpy.c :+: :+: */
/* +:+ */
/* By: rcappend <[email protected]> +#+ */
/* +#+ */
/* Created: 2020/10/29 15:41:31 by rcappend #+# #+# */
/* Updated: 2021/11/03 14:23:37 by rcappend ######## odam.nl */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *temp_dst;
unsigned char *temp_src;
temp_dst = (unsigned char *)dst;
temp_src = (unsigned char *)src;
while (n > 0)
{
*temp_dst = *temp_src;
if (*temp_src == (unsigned char)c)
return (temp_dst + 1);
temp_dst++;
temp_src++;
n--;
}
return (NULL);
}