strcat, wcscat, _mbscat

Append a string.

char*strcat(char*strDestination,constchar*strSource);

wchar_t*wcscat(wchar_t*strDestination,constwchar_t*strSource);

unsignedchar*_mbscat(unsignedchar*strDestination,constunsignedchar*strSource);

Routine Required Header Compatibility
strcat <string.h> ANSI, Win 95, Win NT
wcscat <string.h> or <wchar.h> ANSI, Win 95, Win NT
_mbscat <mbstring.h> Win 95, Win NT

For additional compatibility information, see Compatibility in the Introduction.

Libraries

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 (strDestination). No return value is reserved to indicate an error.

Parameters

strDestination

Null-terminated destination string

strSource

Null-terminated source string

Remarks

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. No overflow checking is performed when strings are copied or appended. The behavior of strcat is undefined if the source and destination strings overlap.

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.

Generic-Text Routine Mappings

TCHAR.H Routine _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined
_tcscat strcat _mbscat wcscat

Example

/* 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 );
}

Output

String = Hello world from strcpy and strcat!

String Manipulation Routines

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