_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 Enhancements 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.
Return Value
Zero if the function was successful or an error code.
Remarks
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. If radix equals 10 and value is negative, the first character of the stored string is the minus sign (–). _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 |
Requirements
Routine |
Required header |
---|---|
_ultoa_s |
<stdlib.h> |
_ultow_s |
<stdlib.h> |
For additional compatibility information, see Compatibility in the Introduction.