strcat、 wcscat、 _mbscat

文字列を追加します。 これらの関数のセキュリティを強化したバージョンを使用できます。「strcat_s、wcscat_s、_mbscat_s」を参照してください。

重要

_mbscat_s は、Windows ランタイムで実行するアプリケーションでは使用できません。 詳細については、「ユニバーサル Windows プラットフォーム アプリでサポートされていない CRT 関数」を参照してください。

構文

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

パラメーター

strDestination
NULL で終わる追加先の文字列。

strSource
NULL で終わる元の文字列。

戻り値

これらの関数は、コピー先文字列 (strDestination) を返します。 エラーを示す戻り値は予約されていません。

解説

strcat 関数は、strSource を strDestination に追加し、結果の文字列の終端に null 文字を付けます。 strSource の先頭の文字は、strDestination の終端の null 文字を上書きします。 コピー元とコピー先の文字列が重なり合っている場合の strcat 関数の動作は未定義です。

重要

strcat が、strDestination を追加する前に、strSource に十分な領域があるかどうかを確認しないことが、バッファー オーバーランの潜在的な原因です。 代わりに strncat を使用することを検討してください。

wcscat 関数と _mbscat 関数は、strcat 関数のワイド文字バージョンとマルチバイト文字バージョンです。 wcscatの引数と戻り値はワイド文字列です。 _mbscatの引数と戻り値はマルチバイト文字列です。 それ以外では、これらの関数の動作は同じです。

C++ では、これらの関数にテンプレートのオーバーロードがあります。このオーバーロードは、これらの関数に対応するセキュリティで保護された新しい関数を呼び出します。 詳細については、「セキュリティ保護されたテンプレート オーバーロード」を参照してください。

汎用テキスト ルーチンのマップ

TCHAR.H ルーチン _UNICODE と _MBCS が定義されていない _MBCS が定義されている _UNICODE が定義されている
_tcscat strcat _mbscat wcscat

要件

ルーチンによって返される値 必須ヘッダー
strcat <string.h>
wcscat <string.h> または <wchar.h>
_mbscat <mbstring.h>

互換性の詳細については、「 Compatibility」を参照してください。

例

strcpy の例を参照してください。

関連項目

文字列操作
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