Jump to: navigation, search


Declared in string.h

In C90, the prototype is:

char *strcpy(char *dest, const char *src);

The C99 prototype is identical but adds the new restrict qualifiers:

char *strcpy(char * restrict dest, const char * restrict src);


The strcpy() function shall copy the null-terminated string pointed to by src to the memory pointed to by dest. Source and destination may not overlap.

Return value

The strcpy() function shall return the pointer dest; the function has no failure mode and no error return.


In standard C, this can be implemented as:

char *strcpy(char *restrict dest, const char *restrict src)
char *strcpy(char *dest, const char* src)
    char *ret = dest;
    while (*dest++ = *src++)
    return ret;

Compilable unit, strictly conforming C90 in implementation namespace; public domain; past reviewers: none; current reviews: none

Non-portable components


Personal tools