-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memccpy.c
33 lines (30 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dskrypny <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/11 21:35:37 by dskrypny #+# #+# */
/* Updated: 2017/12/04 19:10:28 by dskrypny ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
size_t i;
unsigned const char *str;
unsigned char *dest;
unsigned char sym;
i = 0;
dest = (unsigned char *)dst;
str = (unsigned const char *)src;
sym = (unsigned char)c;
while (i < n)
{
if ((*dest++ = *str++) == sym)
return (dest);
i++;
}
return (NULL);
}