Share via


strcat, wcscat, _mbscat

追加字符串。 这些功能的更安全版本可用;请参见 strcat_s, wcscat_s, _mbscat_s

重要

_mbscat_s 不能在运行时的窗口执行的应用程序。有关更多信息,请参见 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
    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>

有关其他的兼容性信息,请参见中介绍的 兼容性

示例

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