Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_memcpy.c File Reference
#include <stdlib.h>
+ Include dependency graph for ft_memcpy.c:

Go to the source code of this file.

Functions

void * ft_memcpy (void *dest, const void *src, size_t n)
 Copies bytes from source to destination.
 

Function Documentation

◆ ft_memcpy()

void * ft_memcpy ( void *  dest,
const void *  src,
size_t  n 
)

Copies bytes from source to destination.

Behavior is undefined for overlapping regions; use ft_memmove for overlap.

Parameters
destDestination memory area.
srcSource memory area.
nNumber of bytes to copy.
Returns
Original dest pointer, or NULL when both pointers are NULL.

Definition at line 25 of file ft_memcpy.c.

26{
27 unsigned char *d;
28 const unsigned char *s;
29
30 if (!dest && !src)
31 return (NULL);
32 d = (unsigned char *)dest;
33 s = (const unsigned char *)src;
34 while (n--)
35 *d++ = *s++;
36 return (dest);
37}

Referenced by ft_strdup(), and ft_strjoin().

+ Here is the caller graph for this function: