String Manipulation (CRT)

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at String Manipulation (CRT).

These routines operate on null-terminated single-byte character, wide-character, and multibyte-character strings. 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

RoutineUse.NET Framework equivalent
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_lCompare two character strings using code page information (_mbsicoll and _mbsnicoll are case-insensitive)System::String::Compare
_strdec, _wcsdec, _mbsdec, _mbsdec_lMove string pointer back one characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_strinc, _wcsinc, _mbsinc, _mbsinc_lAdvance string pointer by one characterNot applicable.
_mbsnbcat, _mbsnbcat_l, _mbsnbcat_s, _mbsnbcat_s_lAppend, at most, first n bytes of one character string to anotherNot applicable.
_mbsnbcmp, _mbsnbcmp_lCompare first n bytes of two character stringsNot applicable.
_strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_lReturn number of character bytes within supplied character countNot applicable.
_mbsnbcpy, _mbsnbcpy_l, _mbsnbcpy_s, _mbsnbcpy_s_lCopy n bytes of stringNot applicable.
_mbsnbicmp, _mbsnbicmp_lCompare n bytes of two character strings, ignoring caseNot applicable.
_mbsnbset, _mbsnbset_lSet first n bytes of character string to specified characterNot applicable.
_strncnt, _wcsncnt, _mbsnbcnt, _mbsnbcnt_l, _mbsnccnt, _mbsnccnt_lReturn number of characters within supplied byte countNot applicable.
_strnextc, _wcsnextc, _mbsnextc, _mbsnextc_lFind next character in stringNot applicable.
_strninc, _wcsninc, _mbsninc, _mbsninc_lAdvance string pointer by n charactersNot applicable.
_strspnp, _wcsspnp, _mbsspnp, _mbsspnp_lReturn pointer to first character in given string that is not in another given stringNot applicable.
_scprintf, _scprintf_l, _scwprintf, _scwprintf_lReturn the number of characters in a formatted stringNot applicable.
_snscanf, _snscanf_l, _snwscanf, _snwscanf_l, _snscanf_s, _snscanf_s_l, _snwscanf_s, _snwscanf_s_lRead formatted data of a specified length from the standard input stream.Not applicable.
sscanf, _sscanf_l, swscanf, _swscanf_l, sscanf_s, _sscanf_s_l, swscanf_s, _swscanf_s_lRead formatted data of a specified length from the standard input stream.Not applicable.
sprintf, _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_lWrite formatted data to a stringSystem::String::Format
strcat, wcscat, _mbscat, strcat_s, wcscat_s, _mbscat_sAppend one string to anotherSystem::String::Concat
strchr, wcschr, _mbschr, _mbschr_lFind first occurrence of specified character in stringSystem::String::IndexOf
strcmp, wcscmp, _mbscmpCompare two stringsSystem::String::CompareOrdinal
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_lCompare two strings using current locale code page information (_stricoll, _wcsicoll, _strnicoll, and _wcsnicoll are case-insensitive)System::String::Compare
strcpy, wcscpy, _mbscpy, strcpy_s, wcscpy_s, _mbscpy_sCopy one string to anotherSystem::String::Copy
strcspn, wcscspn, _mbscspn, _mbscspn_lFind first occurrence of character from specified character set in stringSystem::String::IndexOfAny
_strdup, _wcsdup, _mbsdup, _strdup_dbg, _wcsdup_dbgDuplicate stringSystem::String::Clone
strerror, _strerror, _wcserror, __wcserror, strerror_s, _strerror_s, _wcserror_s, __wcserror_sMap error number to message stringSystem::Exception::Message
strftime, wcsftime, _strftime_l, _wcsftime_lFormat date-and-time stringSystem::Convert::ToString
_stricmp, _wcsicmp, _mbsicmp, _stricmp_l, _wcsicmp_l, _mbsicmp_lCompare two strings without regard to caseSystem::String::Compare
strlen, wcslen, _mbslen, _mbslen_l, _mbstrlen, _mbstrlen_l, strnlen, strnlen_s, wcsnlen, wcsnlen_s, _mbsnlen, _mbsnlen_l, _mbstrnlen, _mbstrnlen_lFind length of stringSystem::String::Length
_strlwr, _wcslwr, _mbslwr, _strlwr_l, _wcslwr_l, _mbslwr_l, _strlwr_s, _strlwr_s_l, _mbslwr_s, _mbslwr_s_l, _wcslwr_s, _wcslwr_s_lConvert string to lowercaseSystem::String::ToLower
strncat, _strncat_l, wcsncat, _wcsncat_l, _mbsncat, _mbsncat_l, strncat_s, _strncat_s_l, wcsncat_s, _wcsncat_s_l, _mbsncat_s, _mbsncat_s_lAppend characters of stringSystem::String::Concat
strncmp, wcsncmp, _mbsncmp, _mbsncmp_lCompare characters of two stringsSystem::String::Compare
strncpy, _strncpy_l, wcsncpy, _wcsncpy_l, _mbsncpy, _mbsncpy_l, strncpy_s, _strncpy_s_l, wcsncpy_s, _wcsncpy_s_l, _mbsncpy_s, _mbsncpy_s_lCopy characters of one string to anotherSystem::String::Copy
_strnicmp, _wcsnicmp, _mbsnicmp, _strnicmp_l, _wcsnicmp_l, _mbsnicmp_lCompare characters of two strings without regard to caseSystem::String::Compare
_strnset, _strnset_l, _wcsnset, _wcsnset_l, _mbsnset, _mbsnset_lSet first n characters of string to specified characterSystem::String::Replace
strpbrk, wcspbrk, _mbspbrk, _mbspbrk_lFind first occurrence of character from one string in another stringSystem::String::IndexOfAny
strrchr, wcsrchr, _mbsrchr, _mbsrchr_lFind last occurrence of given character in stringSystem::String::LastIndexOf
_strrev, _wcsrev, _mbsrev, _mbsrev_lReverse stringNot applicable.
_strset, _strset_l, _wcsset, _wcsset_l, _mbsset, _mbsset_lSet all characters of string to specified characterNot applicable.
strspn, wcsspn, _mbsspn, _mbsspn_lFind first occurrence in a string of a character not found in another stringNot applicable.
strstr, wcsstr, _mbsstr, _mbsstr_lFind first occurrence of specified string in another stringSystem::String::IndexOf
strtok, _strtok_l, wcstok, _wcstok_l, _mbstok, _mbstok_l, strtok_s, _strtok_s_l, wcstok_s, _wcstok_s_l, _mbstok_s, _mbstok_s_lFind next token in stringNot applicable.
_strupr, _strupr_l, _mbsupr, _mbsupr_l, _wcsupr_l, _wcsupr, _strupr_s, _strupr_s_l, _mbsupr_s, _mbsupr_s_l, _wcsupr_s, _wcsupr_s_lConvert string to uppercaseSystem::String::ToUpper
strxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_lTransform string into collated form based on locale-specific informationNot applicable.
vsprintf, _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_lWrite formatted output using a pointer to a list of argumentsSystem::String::Format
vsnprintf, _vsnprintf, _vsnprintf_l, _vsnwprintf, _vsnwprintf_l, vsnprintf_s, _vsnprintf_s, _vsnprintf_s_l, _vsnwprintf_s, _vsnwprintf_s_lWrite formatted output using a pointer to a list of argumentsSystem::String::Format

Run-Time Routines by Category

Show: