mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 01:34:15 +00:00
feat: add ft_memcpy function
This commit is contained in:
18
ft_memcpy.c
Normal file
18
ft_memcpy.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "libft.h"
|
||||
|
||||
void *ft_memcpy(void *dst, const void *src, size_t n)
|
||||
{
|
||||
size_t i;
|
||||
char *srctmp;
|
||||
char *dsttmp;
|
||||
|
||||
i = 0;
|
||||
srctmp = (char *)src;
|
||||
dsttmp = (char *)dst;
|
||||
while (i < n)
|
||||
{
|
||||
dsttmp[i] = srctmp[i];
|
||||
i++;
|
||||
}
|
||||
return (dst);
|
||||
}
|
||||
10
libft.h
10
libft.h
@@ -61,4 +61,14 @@ void *ft_memset(void *b, int c, size_t len);
|
||||
*/
|
||||
void ft_bzero(void *s, size_t n);
|
||||
|
||||
/*
|
||||
The memcpy() function copies n bytes
|
||||
from memory area src to memory area dst.
|
||||
If dst and src overlap, behavior is
|
||||
undefined. Applications in which dst and
|
||||
src might overlap should use memmove(3)
|
||||
instead.
|
||||
*/
|
||||
void *ft_memcpy(void *dst, const void *src, size_t n);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user