ARM Technical Support Knowledge Articles

STRTOD LIBRARY ROUTINE

Applies to: C166 C Compiler

Answer


Information in this article applies to:


QUESTION

What does the strtod library routine do?

ANSWER

The strtod library routine converts the contents of a string to a double. Leading whitespace is ignored. This function is declared as follows:

#include <stdlib.h>
double strtod (
  const char *string,  /* string to convert */
  char *endp);  /* ptr to unconverted text */

A pointer to the first character in string that can't be converted is stored in endp unless endp is NULL.

For example:

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

void tst_strtod (void)  {
  char buf [] = "1234.56 is a big number";
  double barrel;
  char *p;

  barrel = strtod (buf, &p);
}

MORE INFORMATION

SEE ALSO

Article last edited on: 2005-10-20 07:43:51

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential