strcpy, wcscpy, _mbscpy

Copy a string.




Routine Required Header Compatibility
strcpy <string.h> ANSI, Win 95, Win NT
wcscpy <string.h> or <wchar.h> ANSI, Win 95, Win NT
_mbscpy <mbstring.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.


LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version

Return Value

Each of these functions returns the destination string. No return value is reserved to indicate an error.



Destination string


Null-terminated source string


The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. No overflow checking is performed when strings are copied or appended. The behavior of strcpy is undefined if the source and destination strings overlap.

wcscpy and _mbscpy are wide-character and multibyte-character versions of strcpy. The arguments and return value of wcscpy are wide-character strings; those of _mbscpy are multibyte-character strings. These three functions behave identically otherwise.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcscpy strcpy _mbscpy wcscpy


/* STRCPY.C: This program uses strcpy
 * and strcat to build a phrase.

#include <string.h>
#include <stdio.h>

void main( void )
   char string[80];
   strcpy( string, "Hello world from " );
   strcat( string, "strcpy " );
   strcat( string, "and " );
   strcat( string, "strcat!" );
   printf( "String = %s\n", string );


String = Hello world from strcpy and strcat!

String Manipulation Routines

See Also   strcat, strcmp, strncat, strncmp, strncpy, _strnicmp, strrchr, strspn