字符串操作 (CRT)String Manipulation (CRT)

这些例程作用于 null 结尾的单字节字符、宽字符及多字节字符字符串。These routines operate on null-terminated single-byte character, wide-character, and multibyte-character strings. 缓冲区操作中所述,可以将缓冲区操作例程用于不以 null 字符结尾的字符数组。Use the buffer-manipulation routines, described in Buffer Manipulation, to work with character arrays that do not end with a null character.

字符串操作例程String-Manipulation Routines

例程Routine 使用Use
strcoll、wcscoll、_mbscoll、_strcoll_l、_wcscoll_l、_mbscoll_l_stricoll、_wcsicoll、_mbsicoll、_stricoll_l、_wcsicoll_l、_mbsicoll_l_strncoll、_wcsncoll、_mbsncoll、_strncoll_l、_wcsncoll_l、_mbsncoll_l_strnicoll、_wcsnicoll、_mbsnicoll、_strnicoll_l、_wcsnicoll_l、_mbsnicoll_lstrcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_l, _stricoll, _wcsicoll, _mbsicoll, _stricoll_l, _wcsicoll_l, _mbsicoll_l, _strncoll, _wcsncoll, _mbsncoll, _strncoll_l, _wcsncoll_l, _mbsncoll_l, _strnicoll, _wcsnicoll, _mbsnicoll, _strnicoll_l, _wcsnicoll_l, _mbsnicoll_l 使用代码页信息比较两个字符字符串(_mbsicoll_mbsnicoll 区分大小写)Compare two character strings using code page information (_mbsicoll and _mbsnicoll are case-insensitive)
_strdec、_wcsdec、_mbsdec、_mbsdec_l_strdec, _wcsdec, _mbsdec, _mbsdec_l 将字符串指针退后一个字符Move string pointer back one character
_strinc、_wcsinc、_mbsinc、_mbsinc_l_strinc, _wcsinc, _mbsinc, _mbsinc_l 将字符串指针提前一个字符Advance string pointer by one character
_mbsnbcat、_mbsnbcat_l_mbsnbcat_s、_mbsnbcat_s_l_mbsnbcat, _mbsnbcat_l, _mbsnbcat_s, _mbsnbcat_s_l 最多,将一个字符字符串的前 n 个字节追加到另一个字符字符串Append, at most, first n bytes of one character string to another
_mbsnbcmp、_mbsnbcmp_l_mbsnbcmp, _mbsnbcmp_l 比较两个字符字符串的前 n 个字节Compare first n bytes of two character strings
_strncnt、_wcsncnt、_mbsnbcnt、_mbsnbcnt_l、_mbsnccnt、_mbsnccnt_l_strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l 返回提供字符数范围的字符字节数Return number of character bytes within supplied character count
_mbsnbcpy、_mbsnbcpy_l_mbsnbcpy_s、_mbsnbcpy_s_l_mbsnbcpy, _mbsnbcpy_l, _mbsnbcpy_s, _mbsnbcpy_s_l 复制字符串的 n 个字节Copy n bytes of string
_mbsnbicmp、_mbsnbicmp_l_mbsnbicmp, _mbsnbicmp_l 比较两个字符字符串的 n 个字节,忽略大小写Compare n bytes of two character strings, ignoring case
_mbsnbset、_mbsnbset_l_mbsnbset, _mbsnbset_l 将字符串的前 n 个字节设置为指定字符Set first n bytes of character string to specified character
_strncnt、_wcsncnt、_mbsnbcnt、_mbsnbcnt_l、_mbsnccnt、_mbsnccnt_l_strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_l 返回提供的字节数范围内的字符数Return number of characters within supplied byte count
_strnextc、_wcsnextc、_mbsnextc、_mbsnextc_l_strnextc, _wcsnextc, _mbsnextc, _mbsnextc_l 在字符串中查找下一个字符Find next character in string
_strninc、_wcsninc、_mbsninc、_mbsninc_l_strninc, _wcsninc, _mbsninc, _mbsninc_l 将字符串指针前移 n 个字符Advance string pointer by n characters
_strspnp、_wcsspnp、_mbsspnp、_mbsspnp_l_strspnp, _wcsspnp, _mbsspnp, _mbsspnp_l 返回指向给定字符串(不在另一个给定字符串)中的第一个字符的指针Return pointer to first character in given string that is not in another given string
_scprintf、_scprintf_l、_scwprintf、_scwprintf_l_scprintf, _scprintf_l, _scwprintf, _scwprintf_l 返回格式化字符串中的字符数Return the number of characters in a formatted string
_snscanf、_snscanf_l、_snwscanf、_snwscanf_l_snscanf_s、_snscanf_s_l、_snwscanf_s、_snwscanf_s_l_snscanf, _snscanf_l, _snwscanf, _snwscanf_l, _snscanf_s, _snscanf_s_l, _snwscanf_s, _snwscanf_s_l 从标准输入流读取指定长度的格式化数据。Read formatted data of a specified length from the standard input stream.
sscanf、_sscanf_l、swscanf、_swscanf_lsscanf_s、_sscanf_s_l、swscanf_s、_swscanf_s_lsscanf, _sscanf_l, swscanf, _swscanf_l, sscanf_s, _sscanf_s_l, swscanf_s, _swscanf_s_l 从标准输入流读取指定长度的格式化数据。Read formatted data of a specified length from the standard input stream.
sprintf、_sprintf_l、swprintf、_swprintf_l、__swprintf_lsprintf_s、_sprintf_s_l、swprintf_s、_swprintf_s_l_sprintf_p、_sprintf_p_l、_swprintf_p、_swprintf_p_lsprintf, _sprintf_l, swprintf, _swprintf_l, __swprintf_l, sprintf_s, _sprintf_s_l, swprintf_s, _swprintf_s_l, _sprintf_p, _sprintf_p_l, _swprintf_p, _swprintf_p_l 将设置格式的数据写入字符串Write formatted data to a string
strcat、wcscat、_mbscatstrcat_s、wcscat_s、_mbscat_sstrcat, wcscat, _mbscat, strcat_s, wcscat_s, _mbscat_s 将一个字符串追加到另一个字符串Append one string to another
strchr、wcschr、_mbschr、_mbschr_lstrchr, wcschr, _mbschr, _mbschr_l 在字符串中查找指定字符的第一个匹配项Find first occurrence of specified character in string
strcmp、wcscmp、_mbscmpstrcmp, wcscmp, _mbscmp 比较两个字符串Compare two strings
strcoll、wcscoll、_mbscoll、_strcoll_l、_wcscoll_l、_mbscoll_l_stricoll、_wcsicoll、_mbsicoll、_stricoll_l、_wcsicoll_l、_mbsicoll_l_strncoll、_wcsncoll、_mbsncoll、_strncoll_l、_wcsncoll_l、_mbsncoll_l_strnicoll、_wcsnicoll、_mbsnicoll、_strnicoll_l、_wcsnicoll_l、_mbsnicoll_lstrcoll, wcscoll, _mbscoll, _strcoll_l, _wcscoll_l, _mbscoll_l, _stricoll, _wcsicoll, _mbsicoll, _stricoll_l, _wcsicoll_l, _mbsicoll_l, _strncoll, _wcsncoll, _mbsncoll, _strncoll_l, _wcsncoll_l, _mbsncoll_l, _strnicoll, _wcsnicoll, _mbsnicoll, _strnicoll_l, _wcsnicoll_l, _mbsnicoll_l 使用当前区域设置代码页信息比较两个字符串(_stricoll_wcsicoll_strnicoll_wcsnicoll 区分大小写)Compare two strings using current locale code page information (_stricoll, _wcsicoll, _strnicoll, and _wcsnicoll are case-insensitive)
strcpy、wcscpy、_mbscpystrcpy_s、wcscpy_s、_mbscpy_sstrcpy, wcscpy, _mbscpy, strcpy_s, wcscpy_s, _mbscpy_s 将一个字符串复制到另一个字符串Copy one string to another
strcspn、wcscspn、_mbscspn、_mbscspn_lstrcspn, wcscspn, _mbscspn, _mbscspn_l 在字符串中查找指定字符集中的字符的第一个匹配项Find first occurrence of character from specified character set in string
_strdup、_wcsdup、_mbsdup_strdup_dbg、_wcsdup_dbg_strdup, _wcsdup, _mbsdup, _strdup_dbg, _wcsdup_dbg 重复字符串Duplicate string
strerror、_strerror、_wcserror、__wcserrorstrerror_s、_strerror_s、_wcserror_s、__wcserror_sstrerror, _strerror, _wcserror, __wcserror, strerror_s, _strerror_s, _wcserror_s, __wcserror_s 将错误编号映射到消息字符串Map error number to message string
strftime、wcsftime、_strftime_l、_wcsftime_lstrftime, wcsftime, _strftime_l, _wcsftime_l 设置日期和时间字符串的格式Format date-and-time string
_stricmp、_wcsicmp、_mbsicmp、_stricmp_l、_wcsicmp_l、_mbsicmp_l_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_l 比较两个字符串(不考虑大小写)Compare two strings without regard to case
strlen、wcslen、_mbslen、_mbslen_l、_mbstrlen、_mbstrlen_lstrnlen、strnlen_s、wcsnlen、wcsnlen_s、_mbsnlen、_mbsnlen_l、_mbstrnlen、_mbstrnlen_lstrlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l, strnlen, strnlen_s, wcsnlen, wcsnlen_s, _mbsnlen, _mbsnlen_l, _mbstrnlen, _mbstrnlen_l 查找字符串长度Find length of string
_strlwr_s、_strlwr_s_l、_mbslwr_s、_mbslwr_s_l、_wcslwr_s、_wcslwr_s_l_strlwr、_wcslwr、_mbslwr、_strlwr_l、_wcslwr_l、_mbslwr_l_strlwr, _wcslwr, _mbslwr, _strlwr_l, _wcslwr_l, _mbslwr_l, _strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_l 将字符串转换为小写形式Convert string to lowercase
strncat、_strncat_l、wcsncat、_wcsncat_l、_mbsncat、_mbsncat_lstrncat_s、_strncat_s_l、wcsncat_s、_wcsncat_s_l、_mbsncat_s、_mbsncat_s_lstrncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l, strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_l 追加字符串的字符Append characters of string
strncmp、wcsncmp、_mbsncmp、_mbsncmp_lstrncmp, wcsncmp, _mbsncmp, _mbsncmp_l 比较两个字符串的字符Compare characters of two strings
strncpy、_strncpy_l、wcsncpy、_wcsncpy_l、_mbsncpy、_mbsncpy_lstrncpy_s、_strncpy_s_l、wcsncpy_s、_wcsncpy_s_l、_mbsncpy_s、_mbsncpy_s_lstrncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l, strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_l 将一个字符串的字符复制到另一个字符串Copy characters of one string to another
_strnicmp、_wcsnicmp、_mbsnicmp、_strnicmp_l、_wcsnicmp_l、_mbsnicmp_l_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_l 比较两个字符串的字符(不考虑大小写)Compare characters of two strings without regard to case
_strnset、_strnset_l、_wcsnset、_wcsnset_l、_mbsnset、_mbsnset_l_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_l 将字符串的前 n 个字符设置为指定字符Set first n characters of string to specified character
strpbrk、wcspbrk、_mbspbrk、_mbspbrk_lstrpbrk, wcspbrk, _mbspbrk, _mbspbrk_l 在另一个字符串中查找其他字符串中的字符的第一个匹配项Find first occurrence of character from one string in another string
strrchr、wcsrchr、_mbsrchr、_mbsrchr_lstrrchr, wcsrchr, _mbsrchr, _mbsrchr_l 查找字符串中给定字符的最后一个匹配项Find last occurrence of given character in string
_strrev、_wcsrev、_mbsrev、_mbsrev_l_strrev, _wcsrev, _mbsrev, _mbsrev_l 反向字符串Reverse string
_strset、_strset_l、_wcsset、_wcsset_l、_mbsset、_mbsset_l_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_l 将字符串的所有字符设置为指定字符Set all characters of string to specified character
strspn、wcsspn、_mbsspn、_mbsspn_lstrspn, wcsspn, _mbsspn, _mbsspn_l 查找在另一个字符串中找不到的字符的字符串的第一个匹配项Find first occurrence in a string of a character not found in another string
strstr、wcsstr、_mbsstr、_mbsstr_lstrstr, wcsstr, _mbsstr, _mbsstr_l 在另一个字符串中查找指定字符串的第一个匹配项Find first occurrence of specified string in another string
strtok、_strtok_l、wcstok、_wcstok_l、_mbstok、_mbstok_lstrtok_s、_strtok_s_l、wcstok_s、_wcstok_s_l、_mbstok_s、_mbstok_s_lstrtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l, strtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_l 在字符串中查找下一个令牌Find next token in string
_strupr、_strupr_l、_mbsupr、_mbsupr_l、_wcsupr_l、_wcsupr_strupr_s、_strupr_s_l、_mbsupr_s、_mbsupr_s_l、_wcsupr_s、_wcsupr_s_l_strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr, _strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_l 将字符串转换为大写形式Convert string to uppercase
strxfrm、wcsxfrm、_strxfrm_l、_wcsxfrm_lstrxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_l 根据特定于区域设置的信息将字符串转换为排序格式Transform string into collated form based on locale-specific information
vsprintf、_vsprintf_l、vswprintf、_vswprintf_l、__vswprintf_lvsprintf_s、_vsprintf_s_l、vswprintf_s、_vswprintf_s_l_vsprintf_p、_vsprintf_p_l、_vswprintf_p、_vswprintf_p_lvsprintf, _vsprintf_l, vswprintf, _vswprintf_l, __vswprintf_l, vsprintf_s, _vsprintf_s_l, vswprintf_s, _vswprintf_s_l, _vsprintf_p, _vsprintf_p_l, _vswprintf_p, _vswprintf_p_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments
vsnprintf、_vsnprintf、_vsnprintf_l、_vsnwprintf、_vsnwprintf_lvsnprintf_s、_vsnprintf_s、_vsnprintf_s_l、_vsnwprintf_s、_vsnwprintf_s_lvsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l, vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_l 编写使用指针参数列表的格式化输出Write formatted output using a pointer to a list of arguments

另请参阅See Also

按类别分的运行时例程Run-Time Routines by Category