Name

wcstof, wcstod, wcstold
- convert a wide-character string to a double-precision number

Library

libc.lib

Synopsis

  #include <wchar.h>
  float wcstof (const wchar_t * restrict src, wchar_t ** restrict endptr);
  long double wcstold (const wchar_t * restrict src, wchar_t ** restrict endptr);
  double wcstod (const wchar_t * restrict src, wchar_t ** restrict endptr);

Return values


Detailed description

The wcstof, wcstod and wcstold functions are the wide-character versions of the strtof, strtod and strtold functions. Refer to strtod for details.

Examples

#include <wchar.h>
/* Illustrates how to use wcstof API */
int example_wcstof()
{  
  /* src string */
  wchar_t wcs1[21] = L"  1.23abcd";
  wchar_t wcs2[5]=L"abcd";
  wchar_t *eptr;
  float d;
  
 /* convert wide-char string to float */  
  d = wcstof(wcs1, &eptr);
 
  /* compare the result */
  if((d == 1.23F) && !(wcscmp (eptr, wcs2)))
   return 0;
  else
   return 1;
}

         

#include <wchar.h>
/* Illustrates how to use wcstold API */
int example_wcstold()
{  
  /* src string */
  wchar_t wcs1[21] = L"  1.23abcd";
  wchar_t wcs2[5]=L"abcd";
  wchar_t *eptr;
  double d;
 
  /* convert wide-char string to double */
  d = wcstod(wcs1, &eptr);
 
  /* compare the result */
  if((d == 1.23) && !(wcscmp (eptr, wcs2)))
   return 0;
  else
   return 1;
}

         

#include <wchar.h>
/* Illustrates how to use wcstold API */
int example_wcstold()
{  
  /* src string */
  wchar_t wcs1[21] = L"  1.23abcd";
  wchar_t wcs2[5]=L"abcd";
  wchar_t *eptr;
  long double d;
  
  /* convert wide-char string to long double */
  d = wcstold(wcs1, &eptr);
 
  /* compare the result *
  if((d == 1.23) && !(wcscmp (eptr, wcs2)))
   return 0;
  else
  return 1;
}

         


See also

strtod, wcstol
The wcstof, wcstod and wcstold functions conform to -isoC-99.

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top