Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
We recommend using Visual Studio 2017

strcat, wcscat, _mbscat

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at strcat, wcscat, _mbscat.

Appends a string. More secure versions of these functions are available; see strcat_s, wcscat_s, _mbscat_s.

System_CAPS_ICON_important.jpg Important

_mbscat_s cannot be used in applications that execute in the Windows Runtime. For more information, see CRT functions not supported with /ZW.

char *strcat(  
   char *strDestination,  
   const char *strSource   
);  
wchar_t *wcscat(  
   wchar_t *strDestination,  
   const wchar_t *strSource   
);  
unsigned char *_mbscat(  
   unsigned char *strDestination,  
   const unsigned char *strSource   
);  
template <size_t size>  
char *strcat(  
   char (&strDestination)[size],  
   const char *strSource   
); // C++ only  
template <size_t size>  
wchar_t *wcscat(  
   wchar_t (&strDestination)[size],  
   const wchar_t *strSource   
); // C++ only  
template <size_t size>  
unsigned char *_mbscat(  
   unsigned char (&strDestination)[size],  
   const unsigned char *strSource   
); // C++ only  

Parameters

strDestination
Null-terminated destination string.

strSource
Null-terminated source string.

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

The strcat function appends strSource to strDestination and terminates the resulting string with a null character. The initial character of strSource overwrites the terminating null character of strDestination. The behavior of strcat is undefined if the source and destination strings overlap.

System_CAPS_ICON_important.jpg Important

Because strcat does not check for sufficient space in strDestination before appending strSource, it is a potential cause of buffer overruns. Consider using strncat instead.

wcscat and _mbscat are wide-character and multibyte-character versions of strcat. The arguments and return value of wcscat are wide-character strings; those of _mbscat are multibyte-character strings. These three functions behave identically otherwise.

In C++, these functions have template overloads that invoke the newer, secure counterparts of these functions. For more information, see Secure Template Overloads.

Generic-Text Routine Mappings

TCHAR.H routine_UNICODE & _MBCS not defined_MBCS defined_UNICODE defined
_tcscatstrcat_mbscatwcscat
RoutineRequired header
strcat<string.h>
wcscat<string.h> or <wchar.h>
_mbscat<mbstring.h>

For additional compatibility information, see Compatibility.

See the example for strcpy.

System::String::Concat

String Manipulation
strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l
strncmp, wcsncmp, _mbsncmp, _mbsncmp_l
strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l
strrchr, wcsrchr, _mbsrchr, _mbsrchr_l
strspn, wcsspn, _mbsspn, _mbsspn_l

Show: