strcat, wcscat, _mbscat

追加字符串。 提供这些函数的更安全版本;请参阅 strcat_swcscat_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,并使用空字符终止结果字符串。 strSource 的初始字符会覆盖 strDestination 的终止 null 字符。 如果源和目标字符串重叠,则 strcat 的行为是未定义的。

重要

由于 strcat 不会在追加 strSource 前检查 strDestination 中是否有足够空间,所以这可能会造成缓冲区溢出。 请考虑改用 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 的示例。

另请参阅

字符串操作
strncat_strncat_lwcsncat_wcsncat_l_mbsncat_mbsncat_l
strncmpwcsncmp_mbsncmp_mbsncmp_l
strncpy_strncpy_lwcsncpy_wcsncpy_l_mbsncpy_mbsncpy_l
_strnicmp_wcsnicmp_mbsnicmp_strnicmp_l_wcsnicmp_l_mbsnicmp_l
strrchrwcsrchr_mbsrchr_mbsrchr_l
strspnwcsspn_mbsspn_mbsspn_l