Functions That Convert strings to Floating-Point Types
The functions that convert
strings to floating-point types each receive two parameters:
string containing the characters to convert.
• A pointer to a
size_t variable where the function stores the index of the first character that was not converted. The default argument is a null pointer, in which case the function does not store the index.
Consider an example of converting a
string to an floating-point value. Assuming the
string s( "123.45hello" );
the following statement converts the beginning of the
string to the
123.45 and stores that value in convertedDouble:
double convertedDouble = stod( s );
Again, the second argument is a null pointer by default.