-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
executable file
·32 lines (29 loc) · 1.19 KB
/
Copy pathft_memccpy.c
File metadata and controls
executable file
·32 lines (29 loc) · 1.19 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: anben <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/24 11:54:32 by anben #+# #+# */
/* Updated: 2019/06/02 14:57:54 by anben ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dest, const void *src, int c, size_t n)
{
size_t i;
unsigned char *dpos;
unsigned char *spos;
i = 0;
dpos = dest;
spos = (unsigned char *)src;
while (i < n)
{
dpos[i] = spos[i];
if (spos[i] == (unsigned char)c)
return (dpos + i + 1);
i++;
}
return (NULL);
}