-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
33 lines (29 loc) · 1.22 KB
/
ft_memccpy.c
File metadata and controls
33 lines (29 loc) · 1.22 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atimoshe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/28 11:29:24 by atimoshe #+# #+# */
/* Updated: 2020/02/29 15:32:56 by atimoshe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *restrict dst, const void *restrict src, int c, size_t n)
{
size_t i;
i = 0;
unsigned char *ptr;
unsigned char *ptrdst;
ptr = (unsigned char *)src;
ptrdst = (unsigned char *)dst;
while (i < n)
{
ptrdst[i] = ptr[i];
if (ptr[i] == (unsigned char)c)
return (dst + i + 1);
i++;
}
return (NULL);
}