共用方式為


strcat,wcscat _mbscat

附加字串。更多這些函式的可用安全版本,請參閱 strcat_s,wcscat_s _mbscat_s

重要事項重要事項

_mbscat_s 不能用於 Windows 執行階段執行的應用程式。如需詳細資訊,請參閱 CRT 函式不支援使用 /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

參數

  • strDestination
    null 結尾的字串。

  • strSource
    innull 結尾的來源字串。

傳回值

這些函式都會傳回目的字串 (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範例。

.NET Framework 對等用法

System::String::Concat

請參閱

參考

字串操作 (CRT)

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