-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memccpy.c
More file actions
39 lines (36 loc) · 1.31 KB
/
ft_memccpy.c
File metadata and controls
39 lines (36 loc) · 1.31 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
35
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memccpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: salee <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/06/01 12:27:36 by salee #+# #+# */
/* Updated: 2021/06/01 12:27:42 by salee ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memccpy(void *s1, const void *s2, int c, size_t n)
{
unsigned char *s1_2;
unsigned char *s2_2;
unsigned char c2;
unsigned char *return_value;
size_t i;
s1_2 = (unsigned char *)s1;
s2_2 = (unsigned char *)s2;
c2 = (unsigned char)c;
i = 0;
return_value = NULL;
while (i < n)
{
s1_2[i] = s2_2[i];
if (s2_2[i] == c2)
{
return_value = s1_2 + i + 1;
break ;
}
i++;
}
return (return_value);
}