Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
strcpy.c File Reference
#include <string.h>
Include dependency graph for strcpy.c:

Go to the source code of this file.

Functions

char * strcpy (char *__restrict dst, const char *__restrict src)
 Copies the null-terminated byte string pointed to by src to the character array whose first element is pointed to by dest. More...
 

Function Documentation

◆ strcpy()

char* strcpy ( char *__restrict  dst,
const char *__restrict  src 
)

Copies the null-terminated byte string pointed to by src to the character array whose first element is pointed to by dest.

Copies the null-terminated byte string pointed to by src, including the null terminator, to the character array whose first element is pointed to by dest. It may clobber the rest of the destination array with unspecified values and that the following errors are detected at runtime and call the currently installed constraint handler function: The behavior is undefined if the dest array is not large enough. The behavior is undefined if the strings overlap. The behavior is undefined if either dest is not a pointer to a character array or src is not a pointer to a null-terminated byte string. The behavior is undefined if the size of the character array pointed to by dest <= strlen(src, destsz)

Parameters
dstpointer to the character array to write to
srcpointer to the null-terminated byte string to copy from
Returns
a copy of dest

Definition at line 26 of file strcpy.c.

27 {
28  const size_t length = strlen(src);
29  // The stpcpy() and strcpy() functions copy the string src to dst
30  // (including the terminating '\0' character).
31  memcpy(dst, src, length + 1);
32  // The strcpy() and strncpy() functions return dst.
33  return dst;
34 }
size_t strlen(const char *str)
Returns the length of the given null-terminated byte string.
Definition: strlen.c:77
void * memcpy(void *__restrict dest, const void *__restrict src, size_t n)
Copies n characters from the object pointed to by src to the object pointed to by dest.

References memcpy(), and strlen().

Referenced by strxfrm().

Here is the caller graph for this function: