This documentation is archived and is not being maintained.

strcpy, wcscpy, _mbscpy

Copy a string.

char *strcpy(
   char *strDestination,
   const char *strSource 
wchar_t *wcscpy(
   wchar_t *strDestination,
   const wchar_t *strSource 
unsigned char *_mbscpy(
   unsigned char *strDestination,
   const unsigned char *strSource 


Destination string.
Null-terminated source string.

Return Value

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


The strcpy function copies strSource, including the terminating null character, to the location specified by strDestination. The behavior of strcpy is undefined if the source and destination strings overlap.

Security Note   Because strcpy does not check for sufficient space in strDestination before copying strSource, it is a potential cause of buffer overruns. Consider using strncpy instead.

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


Routine Required header Compatibility
strcpy <string.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
wcscpy <string.h> or <wchar.h> ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP
_mbscpy <mbstring.h> Win 98, Win Me, Win NT, Win 2000, Win XP

For additional compatibility information, see Compatibility in the Introduction.


All versions of the C run-time libraries.


// crt_strcpy.c
/* This program uses strcpy
 * and strcat to build a phrase.

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

int main( void )
   char string[80];
   // Note that if you change the previous line to
   //   char string[20];
   // strcpy and strcat will happily overrun the string
   // buffer.  See the examples for strncpy and strncat
   // for safer string handling.
   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!

See Also

String Manipulation Routines | strcat | strcmp | strncat | strncmp | strncpy | _strnicmp | strrchr | strspn | Run-Time Routines and .NET Framework Equivalents