#include <stdlib.h>double strtod(const char *start, char **end);

The strtod( ) function converts the string representation of a number stored in the string pointed to by start into a double and returns the result.

In C99, start and end are qualified by restrict.

The strtod( ) function works as follows. First, any whitespace in the string pointed to by start is stripped. Next, each character that comprises the number is read. Any character that cannot be part of a floating-point number will cause this process to stop. This includes whitespace, punctuation (other than periods), and characters other than E or e. Finally, end is set to point to the remainder, if any, of the original string. This means that if strtod( ) is called with “100.00 Pliers”, the value 100.00 will be returned and end will point to the space that precedes “Pliers”.

If overflow occurs, either HUGE_VAL or –HUGE_VAL (indicating positive or negative overflow) is returned, and the global variable errno is set to ERANGE, indicating a range error. If underflow occurs, the function returns zero and the global variable errno is set to ERANGE. If start does not point to a number, no conversion takes place and zero is returned.

Related functions are atof( ), strtold( ), and strtof( ).

C(s)C++ Programmer's Reference
C Programming on the IBM PC (C Programmers Reference Guide Series)
ISBN: 0673462897
EAN: 2147483647
Year: 2002
Pages: 539 © 2008-2017.
If you may any questions please contact us: