wcstoll - C wchar.h

C examples for wchar.h:wcstoll

Type

function

From


<cwchar>
<wchar.h>

Description

Convert wide string to long long integer

Prototype

long long int strtoll (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 a long int value.

For non valid conversion, a zero value is returned.

For out of the range values, the function returns LLONG_MAX or LLONG_MIN defined in <climits>, and errno is set to ERANGE.

Demo Code


#include <wchar.h>

int main ()//from  ww  w  .j  a  v a 2  s.c  o  m
{
  wchar_t wsNumbers[] = L"1234567805 127b00a12b -01010101010101010101010101100 0x6fdead";
  wchar_t * pEnd;

  long long int lli1, lli2, lli3, lli4;

  lli1 = wcstoll (wsNumbers,&pEnd,10);

  lli2 = wcstoll (pEnd,&pEnd,16);

  lli3 = wcstoll (pEnd,&pEnd,2);

  lli4 = wcstoll (pEnd,NULL,0);

  wprintf (L"The decimal equivalents are: %lld, %lld, %lld and %lld.\n", lli1, lli2, lli3, lli4);

  return 0;
}

Related Tutorials