Prototype
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);
Description
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.
Implementation
In standard C, this can be implemented as:
#ifdef _NC_RESTRICT char *strcpy(char *restrict dest, const char *restrict src) #else char *strcpy(char *dest, const char* src) #endif { 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
References
- The C Standard, 7.21.2.3 (C99 and N1124 numbering)
- strcpy(3) from FreeBSD.org