11.2. Copying Functions

11.2.1. The memcpy function

Synopsis
#include <string.h>

void *memcpy (void * s1 , void * s2 , size_t n );

Description

The memcpy function copies n characters from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.

Returns

The memcpy function returns the value of s1.

See Also

Section 11.2.2

Implementation Notes

11.2.2. The memmove function

Synopsis
#include <string.h>

void *memmove (void * s1 , void * s2 , size_t n );

Description

The memmove function copies n characters from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n characters from the object pointed to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1 and s2, and then the n characters from the temporary array are copied into the object pointed to by s1.

Returns

The memmove function returns the value of s1.

See Also

Section 11.2.1

Implementation Notes

None.

11.2.3. The strcpy function

Synopsis
#include <string.h>

void *strcpy (char * s1 , char * s2 );

Description

The strcpy function copies the string pointed to by s2 (including the terminating null character) into the array pointed to by s1. If copying takes place between objects that overlap then the behavior is undefined.

Returns

The strcpy function returns the value of s1.

Implementation Notes

None.

11.2.4. The strncpy function

Synopsis
#include <string.h>

void *strncpy (char * s1 , char * s2 , size_t n );

Description

The strncpy function copies not more than n characters (characters that follow a null character are not copied) from the array pointed to by s2 to the array pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined.

Returns

The strncpy function returns the value of s1.

Implementation Notes

None.