function
<cwchar>
wcstoul
unsigned long int wcstoul (const wchar_t* str, wchar_t** endptr, int base);
Convert wide string to unsigned long integer
Parses the C wide string str interpreting its content as an integral number of the specified base, which is returned as an unsigned long int value.
This is the wide character equivalent of strtoul (<cstdlib>), interpreting str in the same way.
Parameters
- str
- C wide string containing the representation of an integral number.
- endptr
- Reference to an object of type wchar_t*, whose value is set by the function to the next character in str after the numerical value.
This parameter can also be a null pointer, in which case it is not used.
Return Value
On success, the function returns the converted integral number as an unsigned long int value.
If no valid conversion could be performed, a zero value is returned.
If the value read is out of the range of representable values by an unsigned long int, the function returns ULONG_MAX (defined in <climits>), and errno is set to ERANGE.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
/* wcstoul example */
#include <stdio.h>
#include <wchar.h>
int main ()
{
wchar_t wsInput [256];
unsigned long ul;
wprintf (L"Enter an unsigned number: ");
fgetws (wsInput,256,stdin);
ul = wcstoul (wsInput,NULL,0);
wprintf (L"Value entered: %lu. Its double: %lu\n",ul,ul*2);
return 0;
}
|
Possible output:
Enter an unsigned number: 25
Value entered: 25. Its double: 50
|
See also
- strtoul
- Convert string to unsigned long integer (function)
- wcstol
- Convert wide string to long integer (function)
- wcstod
- Convert wide string to double (function)