-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_memccpy.c
31 lines (28 loc) · 1.2 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: lenzo-pe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/02/09 00:25:38 by lenzo-pe #+# #+# */
/* Updated: 2021/04/07 13:31:06 by lenzo-pe ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_string.h"
void *ft_memccpy(void *dest, const void *src, int chr, size_t num)
{
unsigned char *str1;
unsigned char *str2;
str1 = (unsigned char *)dest;
str2 = (unsigned char *)src;
while (num--)
{
*str1 = *str2;
if (*str1 == (unsigned char)chr)
return ((str1 + 1));
str1++;
str2++;
}
return (NULL);
}