We recommend using Visual Studio 2017

Data Conversion

 

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 Data Conversion.

These routines convert data from one form to another. Generally these routines execute faster than conversions you might write. Each routine that begins with a to prefix is implemented as a function and as a macro. See Choosing Between Functions and Macros for information about choosing an implementation.

Data-Conversion Routines

RoutineUse.NET Framework equivalent
absFind absolute value of integerSystem::Math::Abs
atof, _atof_l, _wtof, _wtof_lConvert string to floatSystem::Convert::ToDouble
atoi, _atoi_l, _wtoi, _wtoi_lConvert string to intSystem::Convert::ToInt32, System::Convert::ToUInt32
_atoi64, _atoi64_l, _wtoi64, _wtoi64_lConvert string to __int64System::Convert::ToInt64, System::Convert::ToUInt64
atol, _atol_l, _wtol, _wtol_lConvert string to longSystem::Convert::ToInt64, System::Convert::ToUInt64
_ecvt, _ecvt_sConvert double to string of specified lengthSystem::Convert::ToString
_fcvt, _fcvt_sConvert double to string with specified number of digits following decimal pointSystem::Convert::ToString
_gcvt, _gcvt_sConvert double number to string; store string in bufferSystem::Convert::ToString
_itoa, _i64toa, _ui64toa, _itow, _i64tow, _ui64tow, _itoa_s, _i64toa_s, _ui64toa_s, _itow_s, _i64tow_s, _ui64tow_sConvert int or __int64 to stringSystem::Convert::ToString
labsFind absolute value of long integerSystem::Math::Abs
_ltoa, _ltow, _ltoa_s, _ltow_sConvert long to stringSystem::Convert::ToString
_mbbtombc, _mbbtombc_lConvert 1-byte multibyte character to corresponding 2-byte multibyte characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbcjistojms, _mbcjistojms_l, _mbcjmstojis, _mbcjmstojis_lConvert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbcjistojms, _mbcjistojms_l, _mbcjmstojis, _mbcjmstojis_lConvert JMS character to JIS characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbctohira, _mbctohira_l, _mbctokata, _mbctokata_lConvert multibyte character to 1-byte hiragana codeNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbctohira, _mbctohira_l, _mbctokata, _mbctokata_lConvert multibyte character to 1-byte katakana codeNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_mbctombb, _mbctombb_lConvert 2-byte multibyte character to corresponding 1-byte multibyte characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
mbstowcs, _mbstowcs_l, mbstowcs_s, _mbstowcs_s_lConvert sequence of multibyte characters to corresponding sequence of wide charactersNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
mbtowc, _mbtowc_lConvert multibyte character to corresponding wide characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
strtod, _strtod_l, wcstod, _wcstod_lConvert string to doubleSystem::Convert::ToDouble
strtol, wcstol, _strtol_l, _wcstol_lConvert string to long integerSystem::Convert::ToInt32
strtoul, _strtoul_l, wcstoul, _wcstoul_lConvert string to unsigned long integerSystem::Convert::ToUInt32
strxfrm, wcsxfrm, _strxfrm_l, _wcsxfrm_lTransform string into collated form based on locale-specific informationSystem::IFormattable::ToString
toascii, __toasciiConvert character to ASCII code
tolower, _tolower, towlower, _tolower_l, _towlower_l, _mbctolower, _mbctolower_l, _mbctoupper, _mbctoupper_lTest character and convert to lowercase if currently uppercaseSystem::Char::ToLower
tolower, _tolower, towlower, _tolower_l, _towlower_lConvert character to lowercase unconditionallySystem::String::ToLower
toupper, _toupper, towupper, _toupper_l, _towupper_l, _mbctolower, _mbctolower_l, _mbctoupper, _mbctoupper_lTest character and convert to uppercase if currently lowercaseSystem::Char::ToUpper
toupper, _toupper, towupper, _toupper_l, _towupper_lConvert character to uppercase unconditionallySystem::String::ToUpper
_ultoa, _ultow, _ultoa_s, _ultow_sConvert unsigned``long to stringSystem::Convert::ToString
wcstombs, _wcstombs_l, wcstombs_s, _wcstombs_s_lConvert sequence of wide characters to corresponding sequence of multibyte charactersNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
wctomb, _wctomb_l, wctomb_s, _wctomb_s_lConvert wide character to corresponding multibyte characterNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
atof, _atof_l, _wtof, _wtof_lConvert wide-character string to a doubleSystem::Convert::ToInt64, System::Convert::ToUInt64, System::Convert::ToSingle, System::Convert::ToDouble
atoi, _atoi_l, _wtoi, _wtoi_lConvert wide-character string to intNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
_atoi64, _atoi64_l, _wtoi64, _wtoi64_lConvert wide-character string to __int64Not applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.
atol, _atol_l, _wtol, _wtol_lConvert wide-character string to longNot applicable. To call the standard C function, use PInvoke. For more information, see Platform Invoke Examples.

Run-Time Routines by Category

Show: