-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_memcpy.c
More file actions
37 lines (34 loc) · 1.62 KB
/
Copy pathft_memcpy.c
File metadata and controls
37 lines (34 loc) · 1.62 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vcodrean <vcodrean@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/16 17:03:40 by vcodrean #+# #+# */
/* Updated: 2022/10/01 10:11:33 by vcodrean ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* Copy n bytes from memory area src to memory area dst
*
* param void dst The destination string.
* param void src The source string.
* param size_t n the number of bytes to copy
*
* return A pointer to the destination string.
*/
void *ft_memcpy(void *dst, const void *src, size_t n) //Copie n bytes del área de memoria src al área de memoria dst
{
unsigned int i;
if (src == NULL && dst == NULL) // si origen o destino son nulos
return (NULL); //retorno null.
i = 0;
while (i < n)// mientra i menor al tamaño de mi buffer
{
((char *)dst)[i] = ((const char *)src)[i]; //igual mi destino de i a la src de i
i++; //aumento i para poder seguir comparando los 2 strings
}
return (dst); //retorno dest modificado.
}