![]() |
![]() |
![]() |
C++ Reference: strtod()
strtod()
Declaration
double strtod(const char* kcpString, char** cppEndPtr);
Description
This function converts a string to floating-point double. The value of the converted double is returned. If the number is either too large or too small to be represented, HUGE_VAL or -HUGE_VAL is returned. If the conversion fails, or if the number is too close to zero, 0 is returned. The argument "kcpString" determines the string thatis converted. The double pointer "cppEndPtr" is set to point to a pointer to the end of the characters in "kcpString" that are converted.
Example
#include <iostream>
#include <cstdlib>
int main() {
using namespace std;
// Convert string to a floating-point double
char caString[] = "3.14159stuff that is not used";
char* cpStopString = 0;
double dNumber = strtod(caString, &cpStopString);
cout << caString << " converts to " << dNumber << endl;
cout << "Stop string = " << cpStopString << endl;
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





