Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stdlib.h>
    double strtod( const char *ptr, char **endptr );
    #include <wchar.h>
    double wcstod( const wchar_t *ptr, wchar_t **endptr );

Description:
    The strtod function converts the string pointed to by ptr to double
    representation.  The function recognizes a string containing:

     .  optional white space,
     .  an optional plus or minus sign,
     .  a sequence of digits containing an optional decimal point,
     .  an optional 'e' or 'E' followed by an optionally signed sequence of
        digits.

    The conversion ends at the first unrecognized character.  A pointer to
    that character will be stored in the object to which endptr points if
    endptr is not NULL.  By comparing the "end" pointer with ptr, it can be
    determined how much of the string, if any, was scanned by the strtod
    function.

    The wcstod function is a wide-character version of strtod that operates
    with wide-character strings.

Returns:
    The strtod function returns the converted value.  If the correct value
    would cause overflow, plus or minus  HUGE_VAL is returned according to
    the sign, and  errno is set to  ERANGE.  If the correct value would
    cause underflow, then zero is returned, and  errno is set to  ERANGE.
     Zero is returned when the input string cannot be converted.  In this
    case,  errno is not set.  When an error has occurred,  errno contains a
    value indicating the type of error that has been detected.

Example:
    #include <stdio.h>
    #include <stdlib.h>

    void main()
      {
        double pi;

        pi = strtod( "3.141592653589793", NULL );
        printf( "pi=%17.15f\n",pi );
      }

Classification:
    strtod is ANSI, wcstod is ANSI

Systems:
     strtod - Math

    wcstod - Math
See Also:
    atof

See Also:

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson