wcstof - C wchar.h

C examples for wchar.h:wcstof

Type

function

From


<cwchar>
<wchar.h>

Description

Convert wide string to float

Prototype

float wcstof (const wchar_t* str, wchar_t** endptr);

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 number as a value of type float.

For non valid conversion, the function returns zero.

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

Demo Code


#include <wchar.h>

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

  d1 = wcstof (str,&pEnd);

  d2 = wcstof (pEnd,NULL);

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

  return 0;
}

Related Tutorials