wcstoul - C wchar.h

C examples for wchar.h:wcstoul

Type

function

From


<cwchar>
<wchar.h>

Description

Convert wide string to unsigned long integer

Prototype

unsigned long int wcstoul (const wchar_t* str, wchar_t** endptr, int base);

Parameters

Parameter Description
str C wide string
endptr the next character in str after the numerical value.

Return 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.

Demo Code


#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;
}

Related Tutorials