-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
34 lines (31 loc) · 1.21 KB
/
ft_memccpy.c
File metadata and controls
34 lines (31 loc) · 1.21 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
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pruthann <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/11/14 15:16:47 by pruthann #+# #+# */
/* Updated: 2020/11/14 15:17:18 by pruthann ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *dst, const void *src, int c, size_t n)
{
unsigned char *str;
const unsigned char *src_true;
unsigned char sign;
str = dst;
src_true = src;
sign = (unsigned char)c;
while (n)
{
*str = *src_true;
if (*src_true == sign)
return (str + 1);
n--;
src_true++;
str++;
}
return (0);
}