wcstod - C wchar.h

C examples for wchar.h:wcstod

Type

function

From


<cwchar>
<wchar.h>

Description

Convert wide string to double

Prototype

double wcstod (const wchar_t* str, wchar_t** endptr);

Parameters

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

Return Value

On success, it returns the converted number as a value of type double.

For non valid conversion, the function returns zero.

For out of the range value, a positive or negative HUGE_VAL is returned, and errno is set to ERANGE.

Demo Code


#include <wchar.h>

int main ()//from  w  ww .  ja va 2s. c  om
{
  wchar_t str[] = L"12365.24 129.53";
  
  wchar_t * pEnd;
  
  double d1, d2;

  d1 = wcstod (str,&pEnd);

  d2 = wcstod (pEnd,NULL);

  wprintf (L"%f\n", d1);
  
  wprintf (L"%f\n", d2);
  
  return 0;
}

Related Tutorials