42_libft/ft_memcpy.c

33 lines
1.1 KiB
C
Raw Permalink Normal View History

2022-09-27 10:29:23 -04:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cchauvet <cchauvet@student.42angoulem +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/27 09:42:11 by cchauvet #+# #+# */
2022-10-04 08:21:55 -04:00
/* Updated: 2022/09/29 11:50:17 by cchauvet ### ########.fr */
2022-09-27 10:29:23 -04:00
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memcpy(void *dest, const void *src, size_t n)
{
char *tab1;
char *tab2;
size_t i;
2022-10-04 08:21:55 -04:00
if (dest == NULL && src == NULL)
return (dest);
2022-09-27 10:29:23 -04:00
tab1 = dest;
tab2 = (void *) src;
i = 0;
while (i < n)
{
2022-10-04 08:21:55 -04:00
tab1[i] = tab2[i];
i++;
2022-09-27 10:29:23 -04:00
}
return (tab1);
}