_ultoa_s, _ultow_s

 

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 _ultoa_s, _ultow_s.

Convert an unsigned long integer to a string. These are versions of _ultoa, _ultow with security enhancements as described in Security Features in the CRT.

errno_t _ultoa_s(  
    unsigned long value,  
    char *str,  
    size_t sizeOfstr,  
    int radix   
);  
errno_t _ultow_s(  
    unsigned long value,  
    wchar_t *str,  
    size_t sizeOfstr,  
    int radix   
);  
template <size_t size>  
errno_t _ultoa_s(  
    unsigned long value,  
    char (&str)[size],  
    int radix   
); // C++ only  
template <size_t size>  
errno_t _ultow_s(  
    unsigned long value,  
    wchar_t (&str)[size],  
    int radix   
); // C++ only  

Parameters

value
Number to be converted.

str
String result.

sizeOfstr
The size of the str in bytes for _ultoa_s or words for _ultow_s.

radix
Base of value.

Zero if the function was successful or an error code.

The _ultoa_s function converts the digits of value to a null-terminated character string and stores the result (up to 33 bytes) in str. The radix argument specifies the base of value, which must be in the range 2 – 36. _ultow_s is a wide character version of _ultoa_s; the second argument of _ultow_s is a wide character strings.

If str is a NULL pointer, or if sizeOfstr is less than or equal to zero, the invalid parameter handler is invoked, as described in Parameter Validation. If execution is allowed to continue, these functions return -1 and set errno to EINVAL or if the value or str out of range of a long integer, these functions will return a -1 and set the errno to ERANGE.

In C++, using these functions is simplified by template overloads; the overloads can infer buffer length automatically (eliminating the need to specify a size argument) and they can automatically replace older, non-secure functions with their newer, secure counterparts. For more information, see Secure Template Overloads.

Generic-Text Routine Mappings

TCHAR.H routine_UNICODE & _MBCS not defined_MBCS defined_UNICODE defined
_ultot_s_ultoa_s_ultoa_s_ultow_s
RoutineRequired header
_ultoa_s<stdlib.h>
_ultow_s<stdlib.h>

For additional compatibility information, see Compatibility in the Introduction.

System::Convert::ToString

Data Conversion
_ultoa, _ultow
_ltoa, _ltow
_ltoa_s, _ltow_s
_ltoa_s, _ltow_s

Show: