C examples for wchar.h:wcstoul
function
<cwchar> <wchar.h>
Convert wide string to unsigned long integer
unsigned long int wcstoul (const wchar_t* str, wchar_t** endptr, int base);
Parameter | Description |
---|---|
str | C wide string |
endptr | the next character in str after the numerical value. |
On success, the function returns the converted integral number as an unsigned long int value.
For non valid conversion, a zero value is returned.
For out of range value, the function returns ULONG_MAX defined in <climits>, and errno is set to ERANGE.
#include <stdio.h> #include <wchar.h> int main ()/* ww w .j a v a 2 s . c om*/ { 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; }